[erlang-bugs] Compiler crash with 'inline_list_funcs' and "fun Fun/Arity" notation

Anthony Ramine n.oxyde@REDACTED
Fri May 17 20:06:35 CEST 2013


Hello,

Shorter test case, showing the problem comes from the inline itself and not inline_list_funcs:

-module(test).
-compile(inline).
-export([foo/0]).

foo() ->
    F = fun bar/1,
    fun (X) when X =:= F -> X end.

bar(X) -> X.

If you run the core_lint pass, you can see where the problem comes from:

$ erlc +clint test.erl
test: illegal guard expression in foo/0

The inliner inlines `when 'erlang':'=:='(X, F)` to `'erlang':'=:='(X, 'bar'/1)` but local fun references can't appear in guards.

I'll try to make a patch.

Regards,

-- 
Anthony Ramine

Le 17 mai 2013 à 10:55, Masatake Daimon a écrit :

> Hello,
> 
> Compiling the following module makes the compiler crash. I'm using
> R16B.
> 
> ===== test.erl =====
> -module(test).
> -compile(inline).
> -compile(inline_list_funcs).
> -export([foo/0]).
> 
> foo() ->
>    lists:map(fun bar/1, [1]).
> 
> bar(X) -> X.
> 
> ===== the crash ====
> % erlc test.erl
> test: function '-foo/0-lists^map/1-0-'/1+15:
>  Internal consistency check failed - please report this bug.
>  Instruction: {move,{x,0},{yy,0}}
>  Error:       {invalid_store,{yy,0},term}:
> 
> 
> Note that the problem disappears with any of these changes:
> 
> * Commenting out "-compile(inline)."
> * Commenting out "-compile(inline_list_funcs)."
> * Changing the definition of foo/0 to:
>      foo() ->
>          lists:map(fun bar/1, []).   % [] instead of [1]
> * Changing the definition of foo/0 to:
>      foo() ->
>          lists:map(fun (A) -> bar(A) end, [1]).
> 
> Regards,
> -- 
> 大門 正岳 <daimon@REDACTED>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs




More information about the erlang-bugs mailing list