aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/sys_core_fold.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-08-07 07:00:14 +0200
committerBjörn Gustavsson <[email protected]>2017-08-07 07:20:29 +0200
commitf59e70ce61913356a67d58e03d6b68c29e983363 (patch)
tree370a0b69f33dc1db37fb79bc249e7402719cb101 /lib/compiler/src/sys_core_fold.erl
parent520310feef0d76c0f99447187f3574408b219ae5 (diff)
downloadotp-f59e70ce61913356a67d58e03d6b68c29e983363.tar.gz
otp-f59e70ce61913356a67d58e03d6b68c29e983363.tar.bz2
otp-f59e70ce61913356a67d58e03d6b68c29e983363.zip
sys_core_fold: Fix unsafe optimization of non-variable apply
The sys_core_fold pass would do an unsafe "optimization" when an apply operation did not have a variable in the function position as in the following example: > cat test1.core module 'test1' ['test1'/2] attributes [] 'i'/1 = fun (_f) -> _f 'test1'/2 = fun (_f, _x) -> apply apply 'i'/1 (_f) (_x) end > erlc test1.core no_file: Warning: invalid function call Reported-by: Mikael Pettersson
Diffstat (limited to 'lib/compiler/src/sys_core_fold.erl')
-rw-r--r--lib/compiler/src/sys_core_fold.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index e0cd6da06f..d73060fb7e 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -395,10 +395,10 @@ expr(#c_receive{clauses=Cs0,timeout=T0,action=A0}=Recv, Ctxt, Sub) ->
expr(#c_apply{anno=Anno,op=Op0,args=As0}=App, _, Sub) ->
Op1 = expr(Op0, value, Sub),
As1 = expr_list(As0, value, Sub),
- case Op1 of
- #c_var{} ->
+ case cerl:is_data(Op1) of
+ false ->
App#c_apply{op=Op1,args=As1};
- _ ->
+ true ->
add_warning(App, invalid_call),
Err = #c_call{anno=Anno,
module=#c_literal{val=erlang},