diff options
author | Anthony Ramine <[email protected]> | 2014-06-08 16:23:28 +0200 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2014-08-07 01:49:47 +0200 |
commit | 84d0edb3c031e6b560946712bdd50028b7d0a9b9 (patch) | |
tree | dc0bb3e996aa8040ef9e3413101324838dbff337 /lib/compiler | |
parent | 48e73c9aeb4fc2062cfc282a9099c5011429818a (diff) | |
download | otp-84d0edb3c031e6b560946712bdd50028b7d0a9b9.tar.gz otp-84d0edb3c031e6b560946712bdd50028b7d0a9b9.tar.bz2 otp-84d0edb3c031e6b560946712bdd50028b7d0a9b9.zip |
Handle return mismatches for calls and primops
Only exit BIFs and the match_fail primop are allowed to run where more than one
value is expected.
Diffstat (limited to 'lib/compiler')
-rw-r--r-- | lib/compiler/src/core_lint.erl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/compiler/src/core_lint.erl b/lib/compiler/src/core_lint.erl index d9653c816d..7edde484ae 100644 --- a/lib/compiler/src/core_lint.erl +++ b/lib/compiler/src/core_lint.erl @@ -368,12 +368,23 @@ expr(#c_receive{clauses=Cs,timeout=T,action=A}, Def, Rt, St0) -> expr(#c_apply{op=Op,args=As}, Def, Rt, St0) -> St1 = apply_op(Op, Def, length(As), St0), return_match(Rt, 1, expr_list(As, Def, St1)); +expr(#c_call{module=#c_literal{val=erlang},name=#c_literal{val=Name},args=As}, + Def, Rt, St0) when is_atom(Name) -> + St1 = expr_list(As, Def, St0), + case erl_bifs:is_exit_bif(erlang, Name, length(As)) of + true -> St1; + false -> return_match(Rt, 1, St1) + end; expr(#c_call{module=M,name=N,args=As}, Def, _Rt, St0) -> St1 = expr(M, Def, 1, St0), St2 = expr(N, Def, 1, St1), expr_list(As, Def, St2); -expr(#c_primop{name=#c_literal{val=A},args=As}, Def, _Rt, St0) when is_atom(A) -> - expr_list(As, Def, St0); +expr(#c_primop{name=#c_literal{val=A},args=As}, Def, Rt, St0) when is_atom(A) -> + St1 = expr_list(As, Def, St0), + case A of + match_fail -> St1; + _ -> return_match(Rt, 1, St1) + end; expr(#c_catch{body=B}, Def, Rt, St) -> return_match(Rt, 1, body(B, Def, 1, St)); expr(#c_try{arg=A,vars=Vs,body=B,evars=Evs,handler=H}, Def, Rt, St0) -> |