Skip to content

Commit

Permalink
fix corner case in dead_code & ie8 (#3494)
Browse files Browse the repository at this point in the history
fixes #3493
  • Loading branch information
alexlamsl committed Oct 17, 2019
1 parent b1279a4 commit 0785a15
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/compress.js
Expand Up @@ -888,8 +888,10 @@ merge(Compressor.prototype, {
});

AST_SymbolRef.DEFMETHOD("is_immutable", function() {
var orig = this.definition().orig;
return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
var def = this.definition();
if (def.orig.length != 1) return false;
var sym = def.orig[0];
return sym instanceof AST_SymbolLambda && def.scope.name === sym;
});

function is_lhs_read_only(lhs, compressor) {
Expand Down
72 changes: 72 additions & 0 deletions test/compress/ie8.js
Expand Up @@ -1887,3 +1887,75 @@ issue_3486_ie8: {
}
expect_stdout: "PASS"
}

issue_3493: {
options = {
dead_code: true,
ie8: false,
}
input: {
var c = "PASS";
(function() {
try {
(function a() {
throw {};
})();
} catch (a) {
a >>= 0;
a && (c = "FAIL");
}
})();
console.log(c);
}
expect: {
var c = "PASS";
(function() {
try {
(function a() {
throw {};
})();
} catch (a) {
a >>= 0;
a && (c = "FAIL");
}
})();
console.log(c);
}
expect_stdout: "PASS"
}

issue_3493_ie8: {
options = {
dead_code: true,
ie8: true,
}
input: {
var c = "PASS";
(function() {
try {
(function a() {
throw {};
})();
} catch (a) {
a >>= 0;
a && (c = "FAIL");
}
})();
console.log(c);
}
expect: {
var c = "PASS";
(function() {
try {
(function a() {
throw {};
})();
} catch (a) {
a >>= 0;
a && (c = "FAIL");
}
})();
console.log(c);
}
expect_stdout: "PASS"
}

0 comments on commit 0785a15

Please sign in to comment.