Skip to content

Commit

Permalink
fix corner case in conditionals (#5713)
Browse files Browse the repository at this point in the history
fixes #5712
  • Loading branch information
alexlamsl authored Oct 14, 2022
1 parent 5411360 commit 5a5200d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions test/compress/conditionals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 5a5200d

Please sign in to comment.