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

confusing error message when eval'ed function calls an undefined function #2

Open
zerth opened this issue Nov 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@zerth
Copy link

zerth commented Nov 22, 2021

-module(thingy).
-export([x/0]).
x() ->
  lists:foldl(fun (E, A) -> some_mod:xyz(E, A) end, [], [1, 2, 3]).
1> c(thingy),power_shell:eval(thingy,x,[]).
** exception error: undefined function lists:foldl/3
     in function  lists:foldl/3
     in call from thingy:x/0
@max-au max-au added the enhancement New feature or request label Nov 23, 2021
@potatosalad
Copy link
Contributor

This seems due to the way the anonymous function is being evaluated after being passed to a built-in function (in this case lists:foldl/3):

-module(thiny).
-export([x/0, y/0, z/0]).
x() ->
    lists:foldl(fun (E, A) -> some_mod:xyz(E, A) end, [], [1, 2, 3]).
y() ->
    some_mod:xyz(1, 2).
z() ->
    (fun(E, A) -> some_mod:xyz(E, A) end)(1, 2).
1> catch power_shell:eval(thingy, x, []).
{'EXIT',{undef,[{lists,foldl,
                       [#Fun<power_shell_eval.43.115918300>,[],[1,2,3]],
                       []},
                {lists,foldl,3,[]},
                {thingy,x,0,[]},
                {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,689}]},
                {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,434}]},
                {shell,exprs,7,[{file,"shell.erl"},{line,686}]},
                {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
                {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}
2> catch power_shell:eval(thingy, y, []).
{'EXIT',{undef,[{some_mod,xyz,[1,2],[]},
                {thingy,y,0,[]},
                {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,689}]},
                {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,434}]},
                {shell,exprs,7,[{file,"shell.erl"},{line,686}]},
                {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
                {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}
3> catch power_shell:eval(thingy, z, []).
{'EXIT',{undef,[{some_mod,xyz,[1,2],[]},
                {thingy,z,0,[]},
                {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,689}]},
                {erl_eval,expr,5,[{file,"erl_eval.erl"},{line,434}]},
                {shell,exprs,7,[{file,"shell.erl"},{line,686}]},
                {shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
                {shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}

max-au added a commit to max-au/power_shell that referenced this issue Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants