From: Alex Lam S.L Date: Wed, 26 Aug 2020 11:45:38 +0000 (+0100) Subject: fix corner case in `evaluate` (#4078) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3aa765e4296c4caf2f3b2b3e6b43b65caf05a28f;p=UglifyJS.git fix corner case in `evaluate` (#4078) fixes #4077 --- diff --git a/lib/compress.js b/lib/compress.js index a1f3d50c..cd790db3 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3502,7 +3502,8 @@ merge(Compressor.prototype, { var left = this.left._eval(compressor, ignore_side_effects, cached, depth); if (left === this.left) return this; if (this.operator == (left ? "||" : "&&")) return left; - var right = this.right._eval(compressor, ignore_side_effects, cached, depth); + var rhs_ignore_side_effects = ignore_side_effects && !(left && typeof left == "object"); + var right = this.right._eval(compressor, rhs_ignore_side_effects, cached, depth); if (right === this.right) return this; var result; switch (this.operator) { diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 9f97ba99..6d4d084d 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2894,3 +2894,17 @@ issue_4067: { } expect_stdout: "NaN" } + +issue_4077: { + options = { + evaluate: true, + unsafe: true, + } + input: { + console.log((a = []) - (a[0]++, 1) || "PASS"); + } + expect: { + console.log((a = []) - (a[0]++, 1) || "PASS"); + } + expect_stdout: "PASS" +}