(fun f/1)() should be compiled to let X = 'f'/1 in apply X () to let the compiler properly generate code that will fail with badarity at runtime.
Do not emit blatantly illformed Core Erlang apply expressions
(fun f/1)() should be compiled to let X = 'f'/1 in apply X () to let the compiler
properly generate code that will fail with badarity at runtime.
Reported-by: Ulf Norell
Thanks! Will run it in our daily builds.
Thinking a little more about this one...
Will this solution always work? What if some Core Erlang optimisation pass would again inline the call of the fun? Would it not be a safer solution to handle this case in v3_kernel or v3_codegen?
@bjorng Core lint specifically reject such code, in my opinion if you handle that elsewhere you should make it valid. I would rather say that such code should never be emitted.
I failed to notice that fun_inline_SUITE.erl failed to compile. That means that the inliner needs to be fixed too (or fixing the problem somewhere else, for instance in v3_kernel).
Interesting, will you fix it yourself as the suite in the repos fails or can I look at it tonight?
You can look at it tonight. I will probably be busy with other things today.
For now I have added to our daily builds a branch that reverts your commit.
@bjorng Oh right, I didn't run this one because I just ran ct_run directly on the compiler test dir. It's quite bothersome to have to run otp_build tests etc, couldn't these kind of suites include the other one with some macro trickery and be included in the repository?
Nevermind, I can just run make -C lib/compiler/test. Will do that now.
make -C lib/compiler/test