fix corner case in `evaluate` (#3739)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 1 Mar 2020 20:34:31 +0000 (20:34 +0000)
committerGitHub <noreply@github.com>
Sun, 1 Mar 2020 20:34:31 +0000 (20:34 +0000)
fixes #3738

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

index e455ea8..ab89e92 100644 (file)
@@ -2528,9 +2528,8 @@ merge(Compressor.prototype, {
                 return left.is_negative_zero() || right.is_negative_zero();
               case "*":
               case "/":
-                return true;
               case "%":
-                return left.is_negative_zero();
+                return true;
               default:
                 return false;
             }
index 09fdfb2..6d3adac 100644 (file)
@@ -2161,3 +2161,16 @@ collapse_vars_regexp: {
         "abbb",
     ]
 }
+
+issue_3738: {
+    options = {
+        evaluate: true,
+    }
+    input: {
+        console.log(1 / (0 + ([] - 1) % 1));
+    }
+    expect: {
+        console.log(1 / (0 + ([] - 1) % 1));
+    }
+    expect_stdout: "Infinity"
+}