fix corner case in ie8 & reduce_vars (#4020)

fixes #4019
This commit is contained in:
Alex Lam S.L
2020-07-21 09:17:02 +01:00
committed by alexlamsl
parent bce3919748
commit cd671221c5
3 changed files with 29 additions and 1 deletions

View File

@@ -894,6 +894,7 @@ merge(Compressor.prototype, {
d.assignments++; d.assignments++;
var fixed = d.fixed; var fixed = d.fixed;
if (safe_to_read(tw, d) && safe_to_assign(tw, d)) { if (safe_to_read(tw, d) && safe_to_assign(tw, d)) {
if (d.single_use) d.single_use = false;
push_ref(d, exp); push_ref(d, exp);
mark(tw, d); mark(tw, d);
d.fixed = function() { d.fixed = function() {

View File

@@ -1729,7 +1729,7 @@ chained_3: {
} }
expect: { expect: {
console.log(function(a, b) { console.log(function(a, b) {
var c = 2; var c = b;
b++; b++;
return c; return c;
}(0, 2)); }(0, 2));

View File

@@ -2634,3 +2634,30 @@ issue_4015: {
} }
expect_stdout: "1" expect_stdout: "1"
} }
issue_4019: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
mangle = {
ie8: true,
toplevel: true,
}
input: {
var a = function() {
try {
console.log("FAIL");
} catch (b) {}
}, a = (console.log(a.length), ++a);
}
expect: {
var o = function() {
try {
console.log("FAIL");
} catch (o) {}
}, o = (console.log(o.length), ++o);
}
expect_stdout: "0"
}