diff options
| author | Björn Gustavsson <[email protected]> | 2015-02-23 10:04:21 +0100 | 
|---|---|---|
| committer | Björn Gustavsson <[email protected]> | 2015-02-23 10:04:21 +0100 | 
| commit | 79736ff7d2e3916356fddda3a03fed8c9d292bdb (patch) | |
| tree | 80524b8914fffe3e268a4730146a989d08c4b9fc /lib/compiler/src | |
| parent | 343a1d3f41ca9655d032e7946b0334b6a361d6be (diff) | |
| parent | 7db06f86efea90df387501735dea39681a82d4ae (diff) | |
| download | otp-79736ff7d2e3916356fddda3a03fed8c9d292bdb.tar.gz otp-79736ff7d2e3916356fddda3a03fed8c9d292bdb.tar.bz2 otp-79736ff7d2e3916356fddda3a03fed8c9d292bdb.zip | |
Merge branch 'bjorn/compiler/sys_core_fold'
* bjorn/compiler/sys_core_fold:
  sys_core_fold: Fix non-tail-recursive list comprehensions
Diffstat (limited to 'lib/compiler/src')
| -rw-r--r-- | lib/compiler/src/sys_core_fold.erl | 15 | 
1 files changed, 11 insertions, 4 deletions
| diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index 7d1819ea15..2618f7adba 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -2288,10 +2288,17 @@ opt_simple_let_2(Let0, Vs0, Arg0, Body, Ctxt, Sub) ->  	    %% No variables left.  	    Body;  	{_,Arg,#c_literal{}} -> -	    %% Since the variable is not used in the body, we can rewrite the -	    %% let to a sequence: -	    %%   let <Var> = Arg in Literal  ==>  seq Arg Literal -	    expr(#c_seq{arg=Arg,body=Body}, Ctxt, sub_new_preserve_types(Sub)); +	    E = case Ctxt of +		    effect -> +			%% Throw away the literal body. +			Arg; +		    value -> +			%% Since the variable is not used in the body, we +			%% can rewrite the let to a sequence. +			%%  let <Var> = Arg in Literal ==> seq Arg Literal +			#c_seq{arg=Arg,body=Body} +		end, +	    expr(E, Ctxt, sub_new_preserve_types(Sub));  	{Vs,Arg,Body} ->  	    %% If none of the variables are used in the body, we can  	    %% rewrite the let to a sequence: | 
