From 5a5200d657f2eb6c37026509afd683fe4f4fc84f Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 14 Oct 2022 16:55:08 +0100 Subject: [PATCH] fix corner case in `conditionals` (#5713) fixes #5712 --- lib/compress.js | 2 +- test/compress/conditionals.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 3099fcde525..cb3cd3653b8 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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; diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index f42cce970e2..66de5c7d24c 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -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" +}