Skip to content

Commit

Permalink
fix corner case in ie (#5959)
Browse files Browse the repository at this point in the history
fixes #5958
  • Loading branch information
alexlamsl authored Oct 30, 2024
1 parent 0acdd83 commit 9d148fb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -14372,6 +14372,7 @@ 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_SymbolLet) return false;
return true;
})) return;
Expand Down
37 changes: 37 additions & 0 deletions test/compress/ie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3474,3 +3474,40 @@ issue_5350_ie: {
}
expect_stdout: "undefined 42"
}

issue_5958: {
options = {
dead_code: true,
evaluate: true,
ie: true,
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"
}

0 comments on commit 9d148fb

Please sign in to comment.