diff --git a/lib/compress.js b/lib/compress.js index d902278dd2..7b1f6c552e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -14372,7 +14372,13 @@ Compressor.prototype.compress = function(node) { if (!all(def.orig, function(sym) { if (sym instanceof AST_SymbolConst) return false; if (sym instanceof AST_SymbolFunarg) return !sym.unused && def.scope.resolve() !== fn; - if (sym instanceof AST_SymbolLambda) return !compressor.option("ie") || sym.scope === def.scope; + if (sym instanceof AST_SymbolLambda) { + if (!compressor.option("ie")) return true; + if (sym.scope === def.scope) return true; + return !all(def.orig, function(decl) { + return !(decl instanceof AST_SymbolVar); + }); + } if (sym instanceof AST_SymbolLet) return false; return true; })) return; diff --git a/test/compress/ie.js b/test/compress/ie.js index 8eb139b5e7..2e049b4f9c 100644 --- a/test/compress/ie.js +++ b/test/compress/ie.js @@ -3476,6 +3476,43 @@ issue_5350_ie: { } issue_5958: { + options = { + dead_code: true, + evaluate: true, + ie: false, + inline: true, + loops: true, + sequences: true, + toplevel: true, + } + input: { + "use strict"; + while (function() { + if (a === console.log("PASS")) { + var a = function b() {}; + try { + a++; + } catch (b) { + b[a]; + } + } + }()); + } + expect: { + "use strict"; + if (a = void 0, a === console.log("PASS")) { + var a = function b() {}; + try { + a++; + } catch (b) { + b[a]; + } + } + } + expect_stdout: "PASS" +} + +issue_5958_ie: { options = { dead_code: true, evaluate: true, @@ -3511,3 +3548,75 @@ issue_5958: { } expect_stdout: "PASS" } + +issue_5961: { + options = { + ie: false, + inline: true, + toplevel: true, + } + input: { + for (var a in [ 1, 2 ]) { + (function() { + try { + (function f() {}); + } finally { + var b = f, f = "FAIL"; + console.log(b || "PASS"); + } + })(); + } + } + expect: { + for (var a in [ 1, 2 ]) { + b = void 0; + f = void 0; + try { + (function f() {}); + } finally { + var b = f, f = "FAIL"; + console.log(b || "PASS"); + } + } + } + expect_stdout: [ + "PASS", + "PASS", + ] +} + +issue_5961_ie: { + options = { + ie: true, + inline: true, + toplevel: true, + } + input: { + for (var a in [ 1, 2 ]) { + (function() { + try { + (function f() {}); + } finally { + var b = f, f = "FAIL"; + console.log(b || "PASS"); + } + })(); + } + } + expect: { + for (var a in [ 1, 2 ]) { + b = void 0; + f = void 0; + try { + (function f() {}); + } finally { + var b = f, f = "FAIL"; + console.log(b || "PASS"); + } + } + } + expect_stdout: [ + "PASS", + "PASS", + ] +}