fix corner case in `evaluate` (#3936)
authorAlex Lam S.L <alexlamsl@gmail.com>
Fri, 29 May 2020 14:10:36 +0000 (15:10 +0100)
committerGitHub <noreply@github.com>
Fri, 29 May 2020 14:10:36 +0000 (22:10 +0800)
fixes #3935

lib/compress.js
test/compress/evaluate.js

index b82ac81..443a649 100644 (file)
@@ -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) {
index a7b5a4a..97b3940 100644 (file)
@@ -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"
+}