maps inside records

Sergej Jurecko <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <[email protected]>
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?


Incorrect behavior 2: 
test1() ->
	Z = #{type => dir,name => "My folder"},
	io:format("Z = ~p ~n",[Z]),
	P = #ev{info = Z},
	io:format("P = ~p ~n",[P]),
	test1(P).
test1(#ev{info = #{type := dir, name := Name}} = E) ->
	io:format("E = ~p ~n",[E]),
	E#ev.info.

Calling test1/0 will print:

ecds:test1().
Z = #{name => "My folder",type => dir} 
P = {ev,#{name => "My folder",type => dir}} 
E = {ev,#{name => "My folder",type => dir}} 
** exception error: bad argument
     in function  ecds:test1/1 

Exception happened in second header of test1, yet E was printed.



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.