[erlang-questions] Preprocessor bug?

Richard Carlsson <>
Thu Feb 21 10:19:23 CET 2008


David King wrote:
> I'm not sure if this is a bug or, if it is a bug, it even needs to be  
> fixed. This code:
> 
> f(F,A) when is_function(F,1) ->
>    F(A);
> f(F,B) when is_function(F,2) ->
>    F(B,B).
> 
> main() ->
>    f(fun(a) -> ... end, a),
>    f(fun(b,b) -> ... end, b).
> 
> compiles and works as expected, unless -compile(inline) is specified.
> If -compile(inline) is specified, the compiler dies with "error:  
> function called with wrong number of arguments!".

Hmm, yes, it's not unreasonable to call it a bug. For now, if you have
fun-calls that are guarded by is_function test that check the arity, you
should not turn on inlining.

I might have a look at it and see if the inliner can be taught about the
is_function/2 test, so it can throw away the unselectable clauses. No
guarantees or time line for that project, though.

     /Richard





More information about the erlang-questions mailing list