fix corner case in comparisons (#4680)

fixes #4679
This commit is contained in:
Alex Lam S.L
2021-02-24 13:38:44 +00:00
committed by GitHub
parent c885660347
commit a5a958beda
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"
}