diff --git a/lib/compress.js b/lib/compress.js index 6b611b73..77d32768 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3294,7 +3294,8 @@ Compressor.prototype.compress = function(node) { function handle_if_return(statements, compressor) { var changed = false; var parent = compressor.parent(); - var in_iife = in_lambda && parent && parent.TYPE == "Call"; + var self = compressor.self(); + var in_iife = in_lambda && parent && parent.TYPE == "Call" && parent.expression === self; var chain_if_returns = in_lambda && compressor.option("conditionals") && compressor.option("sequences"); var multiple_if_returns = has_multiple_if_returns(statements); for (var i = statements.length; --i >= 0;) { @@ -3371,15 +3372,11 @@ Compressor.prototype.compress = function(node) { if (compressor.option("typeofs")) { if (ab && !alt) { - var stats = make_node(AST_BlockStatement, compressor.self(), { - body: statements.slice(i + 1), - }); + var stats = make_node(AST_BlockStatement, self, { body: statements.slice(i + 1) }); mark_locally_defined(stat.condition, null, stats); } if (!ab && alt) { - var stats = make_node(AST_BlockStatement, compressor.self(), { - body: statements.slice(i + 1), - }); + var stats = make_node(AST_BlockStatement, self, { body: statements.slice(i + 1) }); mark_locally_defined(stat.condition, stats); } } diff --git a/test/compress/if_return.js b/test/compress/if_return.js index ac86cf80..5302065c 100644 --- a/test/compress/if_return.js +++ b/test/compress/if_return.js @@ -395,7 +395,31 @@ if_var_return_2: { } } -if_var_return_3: { +if_var_retrn_3: { + options = { + conditionals: true, + if_return: true, + sequences: true, + } + input: { + f(function() { + var a = w(); + if (x()) + return y(a); + z(); + }); + } + expect: { + f(function() { + var a = w(); + if (x()) + return y(a); + z(); + }); + } +} + +if_var_return_4: { options = { conditionals: true, if_return: true,