<div dir="ltr">Thanks! Looks good. I have only two slight comments:<div><br></div><div style>If find the first sentence in the commit message confusing:</div><div style><br></div><div style>"Local fun references look like plain old variables in the Core Erlang</div>
<div><div>AST and should not be treated as such."</div></div><div><br></div><div style>I would suggest "but" instead of "and":</div><div style><br></div><div style><div>"Local fun references look like plain old variables in the Core Erlang</div>
<div>AST, but should not be treated as such."</div></div><div><br></div><div style>The test cases tests that the compiler does not crash and that</div><div style>the code can be loaded, but it does not test that the code actually</div>
<div style>works. I suggest that you rewrite it to something like this:</div><div style><br></div><div style><div>?MODULE() -></div><div>    F = fun bar/1,</div><div>    G = lists:last([(fun (X) when F =:= X -> X end)]),</div>
<div>    F = G(F),</div><div>    ok.</div><div><br></div><div>bar(X) -></div><div>    X.</div><div><br></div></div><div style>/Bjorn</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, May 18, 2013 at 6:22 PM, 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">
Hello,<br>
<br>
This patch fixes the bug by forbidding inlining of variables which values are local fun references outside of application contexts.<br>
<br>
        git fetch <a href="https://github.com/nox/otp.git" target="_blank">https://github.com/nox/otp.git</a> fix-fname-inlining<br>
<br>
        <a href="https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining" target="_blank">https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining</a><br>
        <a href="https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining.patch" target="_blank">https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining.patch</a><br>
<br>
Regards,<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Anthony Ramine<br>
<br>
Le 17 mai 2013 à 20:06, Anthony Ramine a écrit :<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> Hello,<br>
><br>
> Shorter test case, showing the problem comes from the inline itself and not inline_list_funcs:<br>
><br>
> -module(test).<br>
> -compile(inline).<br>
> -export([foo/0]).<br>
><br>
> foo() -><br>
>    F = fun bar/1,<br>
>    fun (X) when X =:= F -> X end.<br>
><br>
> bar(X) -> X.<br>
><br>
> If you run the core_lint pass, you can see where the problem comes from:<br>
><br>
> $ erlc +clint test.erl<br>
> test: illegal guard expression in foo/0<br>
><br>
> The inliner inlines `when 'erlang':'=:='(X, F)` to `'erlang':'=:='(X, 'bar'/1)` but local fun references can't appear in guards.<br>
><br>
> I'll try to make a patch.<br>
><br>
> Regards,<br>
><br>
> --<br>
> Anthony Ramine<br>
><br>
> Le 17 mai 2013 à 10:55, Masatake Daimon a écrit :<br>
><br>
>> Hello,<br>
>><br>
>> Compiling the following module makes the compiler crash. I'm using<br>
>> R16B.<br>
>><br>
>> ===== test.erl =====<br>
>> -module(test).<br>
>> -compile(inline).<br>
>> -compile(inline_list_funcs).<br>
>> -export([foo/0]).<br>
>><br>
>> foo() -><br>
>>   lists:map(fun bar/1, [1]).<br>
>><br>
>> bar(X) -> X.<br>
>><br>
>> ===== the crash ====<br>
>> % erlc test.erl<br>
>> test: function '-foo/0-lists^map/1-0-'/1+15:<br>
>> Internal consistency check failed - please report this bug.<br>
>> Instruction: {move,{x,0},{yy,0}}<br>
>> Error:       {invalid_store,{yy,0},term}:<br>
>><br>
>><br>
>> Note that the problem disappears with any of these changes:<br>
>><br>
>> * Commenting out "-compile(inline)."<br>
>> * Commenting out "-compile(inline_list_funcs)."<br>
>> * Changing the definition of foo/0 to:<br>
>>     foo() -><br>
>>         lists:map(fun bar/1, []).   % [] instead of [1]<br>
>> * Changing the definition of foo/0 to:<br>
>>     foo() -><br>
>>         lists:map(fun (A) -> bar(A) end, [1]).<br>
>><br>
>> Regards,<br>
>> --<br>
>> 大門 正岳 <<a href="mailto:daimon@ymir.co.jp">daimon@ymir.co.jp</a>><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>
><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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB
</div>