diff --git a/lib/compress.js b/lib/compress.js index 831050c9ef..9e0610cc42 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -12270,7 +12270,7 @@ Compressor.prototype.compress = function(node) { return maintain_this_binding(parent, compressor.self(), self.left).optimize(compressor); } else if (!(ll instanceof AST_Node)) { AST_Node.warn("Condition left of && always true [{start}]", self); - return make_sequence(self, [ self.left, self.right ]).optimize(compressor); + return make_sequence(self, [ self.left.clone(), self.right ]).optimize(compressor); } if (!self.right.evaluate(compressor, true)) { if (in_bool && !(self.right.evaluate(compressor) instanceof AST_Node)) { diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index eb8a0583b8..0c1dcccaaf 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -3416,3 +3416,26 @@ issue_5558: { } expect_stdout: "100" } + +issue_5940: { + options = { + conditionals: true, + evaluate: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function f(a) { + f && (console, 42) && (f && (a = [])) && console.log("PASS"); + f = 42; + })(); + } + expect: { + (function f(a) { + f && (console, 42) && (f && []) && console.log("PASS"), + f = 42; + })(); + } + expect_stdout: "PASS" +}