<div dir="ltr"><div>Compiling with erlc +no_copt test_ebug.erl generates no such error. So it looks like an error in core optimization pass.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-13 1:29 GMT+01:00 Dmitry Aleksandrov <span dir="ltr"><<a href="mailto:elixmoon@gmail.com" target="_blank">elixmoon@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<br>
<br>
We found strange behaviour from (As I can judge) erlang compiler, when dealing with records and maps in the same function.<br>
<br>
Here is example:<br>
<br>
-module(test_ebug).<br>
-compile([export_all]).<br>
<br>
-record(session, {args, test}).<br>
<br>
init(#session{args = #{test := Test}}=S) -><br>
io:format(user, "info~n", []),<br>
{ok, [], S#session{test = Test}}.<br>
<br>
test() -> init(#session{args = #{test => 1}}).<br>
<br>
After compiling and test:<br>
<br>
1> test_ebug:test().<br>
info<br>
** exception error: bad argument<br>
in function test_ebug:init/1 (test_ebug.erl, line 6)<br>
<br>
It shows, that info(which happen in line 7), but stacktrace shows line 6, what is wrong. And, this syntax should be correct, because if we make assignment in another function - it works without problem.<br>
<br>
For me, it seems, that core is generated not right on that place(or at least, I do not understand, what is <_fol3> here):<br>
<br>
let <_fol3> =<br>
~{~<'test',Test>}~<br>
in let <_cor3> =<br>
%% Line 8<br>
call 'erlang':'setelement'<br>
(3, S, Test)<br>
in %% Line 8<br>
{'ok',[],_cor3}<br>
<br>
If I replace record syntax, with 'erlang:setelement(3, S, Test)', than core is:<br>
<br>
let <_cor1> =<br>
%% Line 8<br>
call 'erlang':'setelement'<br>
(3, S, Test)<br>
in %% Line 8<br>
{'ok',[],_cor1}<br>
<br>
And its working.<br>
<br>
Should we send it to erlang-bugs?<br>
<br>
Tested on erlang 17.4.<br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</blockquote></div><br></div>