Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing arity check for BIFs #50

Closed
eriksoe opened this issue Feb 13, 2011 · 3 comments
Closed

Missing arity check for BIFs #50

eriksoe opened this issue Feb 13, 2011 · 3 comments

Comments

@eriksoe
Copy link
Contributor

eriksoe commented Feb 13, 2011

To reproduce:

(fun erlang:integer_to_list/1)(1,0).

Expected behaviour:

** exception error: integer_to_list/1 called with two arguments

Observed behaviour:

Expression evaluates to "1".

@krestenkrab
Copy link
Contributor

If I compile

-module(foo).
-export([main/0]).
main() ->
  (fun erlang:integer_to_list/1)(1,0).

And try to run foo:main(), then I get badfun.

> catch(foo:main()).
{'EXIT',{badfun,[{foo,main,[#Fun<erlang:integer_to_list/1>]},
             {erlang,apply,4},
             {error_handler,undefined_function,3},
             {erlang,apply,4},
             {shell,apply_fun,3},
             {erl_eval,do_apply,5},
             {erl_eval,expr,5},
             {shell,exprs,7},
             {shell,eval_exprs,7},
             {shell,eval_loop,3},
             {erlang,apply,4}]}}

However, in BEAM I get

> catch(foo:main()).
{'EXIT',{{badarity,{#Fun<erlang.integer_to_list.1>,[1,0]}},
     [{foo,main,0},
      {erl_eval,do_apply,5},
      {erl_eval,expr,5},
      {shell,exprs,7},
      {shell,eval_exprs,7},
      {shell,eval_loop,3}]}}

So, it's close but no cigar ... we need to throw {badarity,{Fun,Args}} rather than badfun.

@krestenkrab
Copy link
Contributor

Commit 2a0da3f improves this

@eriksoe
Copy link
Contributor Author

eriksoe commented Feb 14, 2011

The behaviour I described was in the shell... so probably an apply() issue.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants