aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_kernel.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-01-04 16:40:31 +0100
committerBjörn Gustavsson <[email protected]>2012-01-11 08:39:57 +0100
commit823f47c8cf3c7a4f32401cae5a2e47916d3593e4 (patch)
tree91a22170ccbb6c50d23e20f0ff35fafda8004bcf /lib/compiler/src/v3_kernel.erl
parent1955804aaf831f943941555ab6f46ee22e5a0dac (diff)
downloadotp-823f47c8cf3c7a4f32401cae5a2e47916d3593e4.tar.gz
otp-823f47c8cf3c7a4f32401cae5a2e47916d3593e4.tar.bz2
otp-823f47c8cf3c7a4f32401cae5a2e47916d3593e4.zip
v3_kernel: Handle sequences in guards
A guard with a sequence will cause a crash in v3_codegen. Currently, it seems that a sequence in a guard will never happen when compiling from Erlang code, but there are several reasons to fix this problem anyway: * There are other compilers that generate Core Erlang code. * Changes to sys_core_fold (perhaps additional optimizations) may cause sequences to be generated in guards. * A previously uncovered line in sys_core_fold:opt_guard_try/1 will now be covered.
Diffstat (limited to 'lib/compiler/src/v3_kernel.erl')
-rw-r--r--lib/compiler/src/v3_kernel.erl7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index 67e22a5662..8bbaf183c8 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -1537,10 +1537,11 @@ uguard_expr(#k_test{anno=A,op=Op,args=As}=Test, Rs, St) ->
Used = union(op_vars(Op), lit_list_vars(As)),
{Test#k_test{anno=#k{us=Used,ns=lit_list_vars(Rs),a=A}},
Used,St};
-uguard_expr(#k_bif{anno=A,op=Op,args=As}=Bif, Rs, St) ->
+uguard_expr(#k_bif{anno=A,op=Op,args=As}=Bif, Rs, St0) ->
Used = union(op_vars(Op), lit_list_vars(As)),
- {Bif#k_bif{anno=#k{us=Used,ns=lit_list_vars(Rs),a=A},ret=Rs},
- Used,St};
+ {Brs,St1} = bif_returns(Op, Rs, St0),
+ {Bif#k_bif{anno=#k{us=Used,ns=lit_list_vars(Brs),a=A},ret=Brs},
+ Used,St1};
uguard_expr(#ivalues{anno=A,args=As}, Rs, St) ->
Sets = foldr2(fun (V, Arg, Rhs) ->
#iset{anno=A,vars=[V],arg=Arg,body=Rhs}