fix corner case in conditionals (#5713)

fixes #5712
This commit is contained in:
Alex Lam S.L
2022-10-14 16:55:08 +01:00
committed by GitHub
parent 5411360829
commit 5a5200d657
2 changed files with 18 additions and 1 deletions

View File

@@ -11809,7 +11809,7 @@ Compressor.prototype.compress = function(node) {
left: self.left.right,
right: self.right,
});
var after = before.optimize(compressor);
var after = before.transform(compressor);
if (before !== after) {
self.left = self.left.left;
self.right = after;

View File

@@ -3051,3 +3051,20 @@ issue_5694: {
}
expect_stdout: "NaN"
}
issue_5712: {
options = {
booleans: true,
conditionals: true,
evaluate: true,
}
input: {
var a = 0;
a || (++a).toString() && a && console.log("PASS");
}
expect: {
var a = 0;
a || (++a).toString() && a && console.log("PASS");
}
expect_stdout: "PASS"
}