Re: maps inside records

Sergej Jurečko <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAAbM2=bQOnPLuSpLVmUkvhGsWJrv=Gx0AaM4-xrz=6qhLLzr9w@mail.gmail.com>
On Mon, Feb 2, 2015 at 8:04 AM, Björn Gustavsson <[email protected]> wrote:

> On Sun, Feb 1, 2015 at 9:47 AM, Sergej Jurecko <[email protected]>
> 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
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.