aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-03-04 12:26:50 +0100
committerBjörn Gustavsson <[email protected]>2014-03-04 12:26:50 +0100
commit77b1aeaa1a663056d228a8d65cdf1daee5bfe51d (patch)
treeb97ca22e0860170eed6acd3fc4adce66a72df86b /lib/compiler/src
parent54a5b030d15b27710c3a54ea363a5b6ec4c2f7c8 (diff)
parent1b8ad68361db59477013bf96e485d5293723ff42 (diff)
downloadotp-77b1aeaa1a663056d228a8d65cdf1daee5bfe51d.tar.gz
otp-77b1aeaa1a663056d228a8d65cdf1daee5bfe51d.tar.bz2
otp-77b1aeaa1a663056d228a8d65cdf1daee5bfe51d.zip
Merge branch 'nox/compiler/v3_core-mismatched-apply'
* nox/compiler/v3_core-mismatched-apply: Do not emit blatantly illformed Core Erlang apply expressions
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/v3_core.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index a50b46bd7b..d3db395995 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -623,7 +623,7 @@ expr({call,Lc,{atom,Lf,F},As0}, St0) ->
Op = #c_var{anno=lineno_anno(Lf, St1),name={F,length(As1)}},
{#iapply{anno=#a{anno=lineno_anno(Lc, St1)},op=Op,args=As1},Aps,St1};
expr({call,L,FunExp,As0}, St0) ->
- {Fun,Fps,St1} = safe(FunExp, St0),
+ {Fun,Fps,St1} = safe_fun(length(As0), FunExp, St0),
{As1,Aps,St2} = safe_list(As0, St1),
Lanno = lineno_anno(L, St2),
{#iapply{anno=#a{anno=Lanno},op=Fun,args=As1},Fps ++ Aps,St2};
@@ -1408,6 +1408,15 @@ safe(E0, St0) ->
{Se,Sps,St2} = force_safe(E1, St1),
{Se,Eps ++ Sps,St2}.
+safe_fun(A0, E0, St0) ->
+ case safe(E0, St0) of
+ {#c_var{name={_,A1}}=E1,Eps,St1} when A1 =/= A0 ->
+ {V,St2} = new_var(St1),
+ {V,Eps ++ [#iset{var=V,arg=E1}],St2};
+ Result ->
+ Result
+ end.
+
safe_list(Es, St) ->
foldr(fun (E, {Ces,Esp,St0}) ->
{Ce,Ep,St1} = safe(E, St0),