<div dir="ltr">Yes, your fix seems to be correct.<div><br></div><div style>Do you think you could write a test case and</div><div style>provide some details in the commit message?</div><div style>(Personally I would put everything into one</div>
<div style>commit.)</div><div style><br></div><div style>I suggest that you end your commit message</div><div style>with:</div><div style><br></div><div style>Reported-by: José Valim</div><div style><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sun, Feb 3, 2013 at 3:28 AM, Anthony Ramine <span dir="ltr"><<a href="mailto:n.oxyde@gmail.com" target="_blank">n.oxyde@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I may have a fix for this:<br>
<br>
        git fetch <a href="https://github.com/nox/otp.git" target="_blank">https://github.com/nox/otp.git</a> fix-seq-opt<br>
<br>
        <a href="https://github.com/nox/otp/compare/erlang:master...fix-seq-opt" target="_blank">https://github.com/nox/otp/compare/erlang:master...fix-seq-opt</a><br>
        <a href="https://github.com/nox/otp/compare/erlang:master...fix-seq-opt.patch" target="_blank">https://github.com/nox/otp/compare/erlang:master...fix-seq-opt.patch</a><br>
<br>
Your bug seems to come from the Core Erlang to Kernel Erlang pass not coping with<br>
multiple values into sequences' arguments, that is expressions which values aren't<br>
used.<br>
<br>
My branch adds a new check to core_lint to detect that kind of invalid code and<br>
fixes sys_core_fold so that it doesn't generate it anymore when optimizing away<br>
unused values.<br>
<br>
To check that this is indeed sys_core_fold's optimizations that makes the<br>
compilation fail, do:<br>
<br>
        erlc +no_copt sample.erl<br>
<br>
To enable the Core Erlang linting pass, do:<br>
<br>
        erlc +clint sample.erl<br>
<br>
Regards,<br>
<br>
--<br>
Anthony Ramine<br>
<br>
Le 2 févr. 2013 à 21:42, José Valim a écrit :<br>
<div><div class="h5"><br>
> Hello everyone,<br>
><br>
> The following module fails to compile using both R15B03-01 and R16A:<br>
><br>
>     -module(sample).<br>
>     -export([hello/1]).<br>
><br>
>     hello(X) -><br>
>       case do_something(X) of<br>
>         false -><br>
>           A = false;<br>
>         Res -><br>
>           { A, B } = Res,<br>
>           do_something(A),<br>
>           do_something(B)<br>
>       end,<br>
>       ThisShouldNotFail = A,<br>
>       ok.<br>
><br>
>     do_something(X) -><br>
>       external:do_something(X).<br>
><br>
> With the following exception:<br>
><br>
>     crash reason: {function_clause,<br>
>                       [{v3_kernel,lit_vars,<br>
>                            [{ivalues,<br>
>                                 [11,{file,"sample.erl"}],<br>
>                                 [{k_var,[],ker4},{k_atom,[],ok}]}],<br>
>                            [{file,"v3_kernel.erl"},{line,1749}]},<br>
>                        {v3_kernel,uexpr,3,[{file,"v3_kernel.erl"},{line,1628}]},<br>
>                        {v3_kernel,ubody,3,[{file,"v3_kernel.erl"},{line,1408}]},<br>
>                        {v3_kernel,ubody,3,[{file,"v3_kernel.erl"},{line,1409}]},<br>
>                        {v3_kernel,umatch,3,[{file,"v3_kernel.erl"},{line,1716}]},<br>
>                        {v3_kernel,'-umatch_list/3-anonymous-0-',3,<br>
>                            [{file,"v3_kernel.erl"},{line,1735}]},<br>
>                        {v3_kernel,umatch,3,[{file,"v3_kernel.erl"},{line,1711}]},<br>
>                        {v3_kernel,'-umatch_list/3-anonymous-0-',3,<br>
>                            [{file,"v3_kernel.erl"},{line,1735}]}]}<br>
><br>
> The code and exceptions are also available here: <a href="https://gist.github.com/7bd4eea30cd187e68caa" target="_blank">https://gist.github.com/7bd4eea30cd187e68caa</a><br>
><br>
> Removing the `ThisShouldNotFail` assignment makes it work correctly, although I wouldn't expect it to explode with that line and just output a couple warnings instead.<br>
><br>
> This snippet was extract from a more complex code. The name of the functions, module and variables do not seem to affect the failure.<br>
><br>
> I tried to further debug the issue but I could not pinpoint the failure. Let me know if I can help any further.<br>
><br>
> Thank you for your time,<br>
><br>
><br>
> José Valim<br>
> <a href="http://www.plataformatec.com.br" target="_blank">www.plataformatec.com.br</a><br>
> Founder and Lead Developer<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> erlang-bugs mailing list<br>
> <a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
<br>
_______________________________________________<br>
erlang-bugs mailing list<br>
<a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB
</div>