diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-05-30 11:22:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-30 18:22:40 +0800 |
commit | 0eb4577a82437a82bd88bfeef4ecc761cc66c861 (patch) | |
tree | 0ff9ee713559840b1341f54144ecf8d978166a5c | |
parent | 43498769f09e682af27999e138ab2d42cea5ef6e (diff) | |
download | tracifyjs-0eb4577a82437a82bd88bfeef4ecc761cc66c861.tar.gz tracifyjs-0eb4577a82437a82bd88bfeef4ecc761cc66c861.zip |
fix corner case in `evaluate` (#3938)
fixes #3937
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/evaluate.js | 21 |
2 files changed, 22 insertions, 1 deletions
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" +} |