fix corner case in dead_code (#3969)

fixes #3967
This commit is contained in:
Alex Lam S.L
2020-06-08 06:42:09 +01:00
committed by GitHub
parent 3230952d57
commit cd55eeb77c
2 changed files with 23 additions and 1 deletions

View File

@@ -3938,7 +3938,8 @@ merge(Compressor.prototype, {
});
def(AST_Binary, function(compressor) {
return this.left.may_throw(compressor)
|| this.right.may_throw(compressor);
|| this.right.may_throw(compressor)
|| this.operator == "in" && !is_object(this.right.tail_node());
});
def(AST_Block, function(compressor) {
return any(this.body, compressor);

View File

@@ -1193,3 +1193,24 @@ self_assignments: {
}
expect_stdout: "PASS 2 PASS PASS"
}
issue_3967: {
options = {
dead_code: true,
}
input: {
var a = "FAIL";
try {
a = 0 in (a = "PASS");
} catch (e) {}
console.log(a);
}
expect: {
var a = "FAIL";
try {
a = 0 in (a = "PASS");
} catch (e) {}
console.log(a);
}
expect_stdout: "PASS"
}