aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-29 15:10:36 +0100
committerGitHub <noreply@github.com>2020-05-29 22:10:36 +0800
commit43498769f09e682af27999e138ab2d42cea5ef6e (patch)
treec618e2858fdd6d56e6935c65cf5e2ffc33a05501
parent60c0bc1e6b1db1a7288c7924231b28a0e9f35cff (diff)
downloadtracifyjs-43498769f09e682af27999e138ab2d42cea5ef6e.tar.gz
tracifyjs-43498769f09e682af27999e138ab2d42cea5ef6e.zip
fix corner case in `evaluate` (#3936)
fixes #3935
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/evaluate.js15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index b82ac811..443a6491 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3430,7 +3430,7 @@ merge(Compressor.prototype, {
var v = e._eval(compressor, ignore_side_effects, cached, depth + 1);
if (v === e) return this;
modified(e);
- return v;
+ return +v;
});
var non_converting_binary = makePredicate("&& || === !==");
def(AST_Binary, function(compressor, ignore_side_effects, cached, depth) {
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index a7b5a4a5..97b39407 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -2654,3 +2654,18 @@ issue_3933: {
}
expect_stdout: "PASS"
}
+
+issue_3935: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ console.log(function f(a) {
+ return a++;
+ }());
+ }
+ expect: {
+ console.log(NaN);
+ }
+ expect_stdout: "NaN"
+}