diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-03-30 12:13:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 19:13:14 +0800 |
commit | dc0cd088cf83e222f135c7d06c31f9a104fe1019 (patch) | |
tree | 440512f25182eeacbc26b30f4c39fad41ea37490 | |
parent | c69c0267289d993638a3ec94461527da54a5919f (diff) | |
download | tracifyjs-dc0cd088cf83e222f135c7d06c31f9a104fe1019.tar.gz tracifyjs-dc0cd088cf83e222f135c7d06c31f9a104fe1019.zip |
fix corner case in `evaluate` & `unsafe_math` (#3756)
fixes #3755
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/evaluate.js | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 343994e7..72690fef 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3243,6 +3243,7 @@ merge(Compressor.prototype, { } if (isNaN(result)) return compressor.find_parent(AST_With) ? this : result; if (compressor.option("unsafe_math") + && !ignore_side_effects && result && typeof result == "number" && (this.operator == "+" || this.operator == "-")) { diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 6d3adacb..e7f6f7eb 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2174,3 +2174,19 @@ issue_3738: { } expect_stdout: "Infinity" } + +issue_3755: { + options = { + booleans: true, + evaluate: true, + unsafe: true, + unsafe_math: true, + } + input: { + console.log((/4/.exec(1 + (!0 - 5 / "23")) || 0).p); + } + expect: { + console.log((/4/.exec(!0 - 5 / "23" + 1), 0).p); + } + expect_stdout: "undefined" +} |