From: Alex Lam S.L Date: Sat, 30 May 2020 10:22:40 +0000 (+0100) Subject: fix corner case in `evaluate` (#3938) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0eb4577a82437a82bd88bfeef4ecc761cc66c861;p=UglifyJS.git fix corner case in `evaluate` (#3938) fixes #3937 --- diff --git a/lib/compress.js b/lib/compress.js index 443a6491..07916323 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3493,7 +3493,7 @@ merge(Compressor.prototype, { var fixed = this.fixed_value(); if (!fixed) return this; var value; - if (member(fixed, cached)) { + if (HOP(fixed, "_eval")) { value = fixed._eval(); } else { this._eval = return_this; diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 97b39407..0cf1d892 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2669,3 +2669,24 @@ issue_3935: { } expect_stdout: "NaN" } + +issue_3937: { + options = { + conditionals: true, + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + } + input: { + var a = 123; + (a++ + (b = a))[b] ? 0 ? a : b : 0 ? a : b; + console.log(a, b); + } + expect: { + var a = 123; + (a++ + (b = a))[b], 0, b; + console.log(a, b); + } + expect_stdout: "124 124" +}