Skip to content

Commit

Permalink
fix corner case in ie8 & reduce_vars (#3919)
Browse files Browse the repository at this point in the history
fixes #3918
  • Loading branch information
alexlamsl committed May 22, 2020
1 parent fa14a9c commit 75c5b60
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -7515,6 +7515,8 @@ merge(Compressor.prototype, {
scope.inlined = true;
} while (scope = scope.parent_scope);
}
} else if (compressor.option("ie8") && fixed.name && def !== fixed.name.definition()) {
single_use = false;
}
if (single_use) fixed.parent_scope = self.scope;
} else if (!fixed || !fixed.is_constant_expression()) {
Expand Down
33 changes: 33 additions & 0 deletions test/compress/ie8.js
Original file line number Diff line number Diff line change
Expand Up @@ -2489,3 +2489,36 @@ issue_3889: {
}
expect_stdout: "undefined"
}

issue_3918: {
options = {
conditionals: true,
ie8: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
mangle = {
ie8: true,
}
input: {
if (console.log("PASS")) {
var a = function f() {
f.p;
try {
console.log("FAIL");
} catch (e) {}
}, b = a;
}
}
expect: {
var a;
console.log("PASS") && (a = function f() {
f.p;
try {
console.log("FAIL");
} catch (o) {}
}, a);
}
expect_stdout: "PASS"
}

0 comments on commit 75c5b60

Please sign in to comment.