[erlang-bugs] maps inside records

Vlad Dumitrescu vladdu55@REDACTED
Mon Feb 2 10:10:49 CET 2015


Sorry, you're right, I just skimmed your code...

This is certainly a bug, as accessing the info field (in any way) returns a
truncated map.

regards,
Vlad


On Mon, Feb 2, 2015 at 9:14 AM, Sergej Jurečko <sergej.jurecko@REDACTED>
wrote:

> Oh right. The #event is just in the print string, not the actual code. The
> code compiles and runs.
>
>
> Sergej
>
> On Mon, Feb 2, 2015 at 9:06 AM, Vlad Dumitrescu <vladdu55@REDACTED>
> wrote:
>
>> Hi Sergej,
>>
>> Is the code you pasted in the mails correct? You have references to both
>> #event and #ev -- maybe that's the cause?
>>
>> regards,
>> Vlad
>>
>>
>> On Mon, Feb 2, 2015 at 8:23 AM, Sergej Jurečko <sergej.jurecko@REDACTED>
>> wrote:
>>
>>>
>>>
>>> On Mon, Feb 2, 2015 at 8:04 AM, Björn Gustavsson <bjorn@REDACTED>
>>> wrote:
>>>
>>>> On Sun, Feb 1, 2015 at 9:47 AM, Sergej Jurecko <
>>>> sergej.jurecko@REDACTED> wrote:
>>>> > Tested in 17.3 and 17.4
>>>> >
>>>> > Incorrect behavior 1:
>>>> >
>>>> > -record(ev,{info}).
>>>> > test() ->
>>>> >         test(#ev{info = #{type => dir, name => "My folder"}}).
>>>> > test(#ev{info = #{type := dir} = I} = E) ->
>>>> >         io:format("E = ~p~n",[E]),
>>>> >         io:format("E#event.info = ~p~n",[E#ev.info]),
>>>> >         io:format("I = ~p~n",[I]).
>>>> >
>>>> > Calling test/0 will print:
>>>> > E = {ev,#{name => "My folder",type => dir}}
>>>> > E#event.info = #{type => dir}
>>>> > I = #{name => "My folder",type => dir}
>>>> >
>>>> > Why is E#event.info without name field?
>>>> >
>>>>
>>>> The behaviour is the expected.
>>>>
>>>> Records are compile-time construct that are translated
>>>> to tuples. So at run-time the record is a tuple and
>>>> will be printed as a tuple.
>>>>
>>>
>>>
>>> Yes but E#event.info value is not a record. It is a map which should
>>> contain #{type => dir, name => "My folder"}, yet when trying to extract
>>> that record we only get #{type => dir}.
>>>
>>> E#event.info should be the same as I, yet it is not.
>>>
>>>
>>> Sergej
>>>
>>> _______________________________________________
>>> erlang-bugs mailing list
>>> erlang-bugs@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-bugs
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150202/858be0c6/attachment.htm>


More information about the erlang-bugs mailing list