diff --git a/lib/compress.js b/lib/compress.js index f408195e..d86b2df5 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3620,7 +3620,7 @@ Compressor.prototype.compress = function(node) { continue; } - if (jump && jump === next) eliminate_returns(stat); + if (declare_only && jump && jump === next) eliminate_returns(stat); } return changed; @@ -3787,6 +3787,7 @@ Compressor.prototype.compress = function(node) { if (stat instanceof AST_Exit) { var mode = match_return(stat, true); if (mode) { + changed = true; var value = trim_return(stat.value, mode); if (value) return make_node(AST_SimpleStatement, value, { body: value }); return in_block ? null : make_node(AST_EmptyStatement, stat); diff --git a/test/compress/if_return.js b/test/compress/if_return.js index abe26073..7ad20043 100644 --- a/test/compress/if_return.js +++ b/test/compress/if_return.js @@ -2305,3 +2305,56 @@ issue_5597: { } expect_stdout: "PASS" } + +issue_5619_1: { + options = { + if_return: true, + } + input: { + console.log(function() { + if (console) + if (console) + return "PASS"; + var a = FAIL; + return "PASS"; + }()); + } + expect: { + console.log(function() { + if (console) + if (console) + return "PASS"; + var a = FAIL; + return "PASS"; + }()); + } + expect_stdout: "PASS" +} + +issue_5619_2: { + options = { + dead_code: true, + if_return: true, + loops: true, + } + input: { + console.log(function() { + if (console) + while (console) + return "PASS"; + var a = FAIL; + return "PASS"; + }()); + } + expect: { + console.log(function() { + if (console) { + if (console) + return "PASS"; + } + var a = FAIL; + return "PASS"; + }()); + } + expect_stdout: "PASS" +}