diff options
author | Anthony Ramine <[email protected]> | 2013-02-03 02:48:04 +0100 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2013-02-03 12:31:07 +0100 |
commit | 8784fdc88e32979ee2186500735ff4ada6190e15 (patch) | |
tree | b160e62428ec5604d0f48fc291b40b918d8b7470 /lib | |
parent | 68b804f34d4ec420d86953e3f519179a40fbee8f (diff) | |
download | otp-8784fdc88e32979ee2186500735ff4ada6190e15.tar.gz otp-8784fdc88e32979ee2186500735ff4ada6190e15.tar.bz2 otp-8784fdc88e32979ee2186500735ff4ada6190e15.zip |
Forbid multiple values in Core Erlang sequence arguments
It does not make sense to return multiple values from a sequence
argument and the Kernel Erlang passes can't cope with it.
The linting pass now knows how to detect this kind of defunct code and
the Core code folding pass is changed to not generate code like that
when optimizing away multiple-valued lets in effect mode.
Reported-by: José Valim
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/src/core_lint.erl | 2 | ||||
-rw-r--r-- | lib/compiler/src/sys_core_fold.erl | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/compiler/src/core_lint.erl b/lib/compiler/src/core_lint.erl index 8b688df830..1e8983f594 100644 --- a/lib/compiler/src/core_lint.erl +++ b/lib/compiler/src/core_lint.erl @@ -309,7 +309,7 @@ expr(#c_fun{vars=Vs,body=B}, Def, Rt, St0) -> {Vvs,St1} = variable_list(Vs, St0), return_match(Rt, 1, body(B, union(Vvs, Def), any, St1)); expr(#c_seq{arg=Arg,body=B}, Def, Rt, St0) -> - St1 = expr(Arg, Def, any, St0), %Ignore values + St1 = expr(Arg, Def, 1, St0), body(B, Def, Rt, St1); expr(#c_let{vars=Vs,arg=Arg,body=B}, Def, Rt, St0) -> St1 = body(Arg, Def, let_varcount(Vs), St0), %This is a body diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index d5fec0c869..c35eef58de 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -132,7 +132,12 @@ body(Body, Sub) -> body(#c_values{anno=A,es=Es0}, Ctxt, Sub) -> Es1 = expr_list(Es0, Ctxt, Sub), - #c_values{anno=A,es=Es1}; + case Ctxt of + value -> + #c_values{anno=A,es=Es1}; + effect -> + make_effect_seq(Es1, Sub) + end; body(E, Ctxt, Sub) -> ?ASSERT(verify_scope(E, Sub)), expr(E, Ctxt, Sub). |