fix corner case in comparisons

fixes #4679
This commit is contained in:
alexlamsl 2021-02-24 19:06:27 +08:00
parent c885660347
commit 0b759e0e3c
2 changed files with 21 additions and 0 deletions

View File

@ -3618,6 +3618,8 @@ merge(Compressor.prototype, {
return this.left.is_defined(compressor) && this.right.is_defined(compressor);
case "||":
return this.left.is_truthy() || this.right.is_defined(compressor);
case "??":
return this.left.is_defined(compressor) || this.right.is_defined(compressor);
default:
return true;
}

View File

@ -109,3 +109,22 @@ conditional_assignment_4: {
expect_stdout: "PASS"
node_version: ">=14"
}
issue_4679: {
options = {
comparisons: true,
ie8: true,
}
input: {
var a;
if (void 0 === (undefined ?? a))
console.log("PASS");
}
expect: {
var a;
if (void 0 === (undefined ?? a))
console.log("PASS");
}
expect_stdout: "PASS"
node_version: ">=14"
}