[erlang-questions] Preprocessor bug?

David King dking@REDACTED
Thu Feb 21 04:48:18 CET 2008


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) ->
         io:format("f(g/1): ~p~n",[a])
     end, a),
   f(fun(b,b) ->
         io:format("f(g/2): ~p~n",[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!". I would think that  
when the pre-processor can't determine at pre-compile time which  
clause to run, it just wouldn't run one, but this is a mess I know I'm  
getting into when I use -compile(inline), so it might not even matter.



More information about the erlang-questions mailing list