aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-24 13:38:44 +0000
committerGitHub <noreply@github.com>2021-02-24 13:38:44 +0000
commita5a958beda5e0e7daedd5bd0cb4c72a81aade19b (patch)
tree99c04f4b16a8d0c42669bd377afb89fe664e1b78
parentc88566034756eb17c4ff563901b3a1c95b63f788 (diff)
downloadtracifyjs-a5a958beda5e0e7daedd5bd0cb4c72a81aade19b.tar.gz
tracifyjs-a5a958beda5e0e7daedd5bd0cb4c72a81aade19b.zip
fix corner case in `comparisons` (#4680)
fixes #4679
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/nullish.js19
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7f9a8dd5..93023e19 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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;
}
diff --git a/test/compress/nullish.js b/test/compress/nullish.js
index e8f5ad6c..a8526cac 100644
--- a/test/compress/nullish.js
+++ b/test/compress/nullish.js
@@ -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"
+}