aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-03-05 02:44:30 +0100
committerBjörn Gustavsson <[email protected]>2014-03-05 12:16:36 +0100
commit313c6f2cdb7ebd9d64dcb333e031045ccaf43531 (patch)
tree216f047e4766038f7c075fb9603560ea21475215 /lib/compiler/src
parentc199bd2923e7d733e60beb9bd27b3852cbb2e699 (diff)
downloadotp-313c6f2cdb7ebd9d64dcb333e031045ccaf43531.tar.gz
otp-313c6f2cdb7ebd9d64dcb333e031045ccaf43531.tar.bz2
otp-313c6f2cdb7ebd9d64dcb333e031045ccaf43531.zip
Do not export variables from comprehension cases in v3_core
Code like the following snippet could make the compiler crash: f() -> [X = a || false] ++ [X = a || false]. Reported-by: Ulf Norell
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/v3_core.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index d3db395995..bb6a51b151 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -1765,13 +1765,16 @@ uexpr(#iletrec{anno=A,defs=Fs0,body=B0}, Ks, St0) ->
{B1,St2} = uexprs(B0, Ks, St1),
Used = used_in_any(map(fun ({_,F}) -> F end, Fs1) ++ B1),
{#iletrec{anno=A#a{us=Used,ns=[]},defs=Fs1,body=B1},St2};
-uexpr(#icase{anno=A,args=As0,clauses=Cs0,fc=Fc0}, Ks, St0) ->
+uexpr(#icase{anno=#a{anno=Anno}=A,args=As0,clauses=Cs0,fc=Fc0}, Ks, St0) ->
%% As0 will never generate new variables.
{As1,St1} = uexpr_list(As0, Ks, St0),
{Cs1,St2} = uclauses(Cs0, Ks, St1),
{Fc1,St3} = uclause(Fc0, Ks, St2),
Used = union(used_in_any(As1), used_in_any(Cs1)),
- New = new_in_all(Cs1),
+ New = case member(list_comprehension, Anno) of
+ true -> [];
+ false -> new_in_all(Cs1)
+ end,
{#icase{anno=A#a{us=Used,ns=New},args=As1,clauses=Cs1,fc=Fc1},St3};
uexpr(#ifun{anno=A0,id=Id,vars=As,clauses=Cs0,fc=Fc0,name=Name}, Ks0, St0) ->
Avs = lit_list_vars(As),