fix corner case in `evaluate` (#3685)
authorAlex Lam S.L <alexlamsl@gmail.com>
Wed, 15 Jan 2020 17:51:37 +0000 (01:51 +0800)
committerGitHub <noreply@github.com>
Wed, 15 Jan 2020 17:51:37 +0000 (01:51 +0800)
fixes #3684

lib/compress.js
test/compress/numbers.js

index ffa5a64..a3baa7b 100644 (file)
@@ -2497,9 +2497,10 @@ merge(Compressor.prototype, {
                     && (!(right instanceof AST_Constant) || right.value == 0);
               case "&&":
               case "||":
-              case "*":
                 return left.is_negative_zero() || right.is_negative_zero();
+              case "*":
               case "/":
+                return true;
               case "%":
                 return left.is_negative_zero();
               default:
index fdfb6c2..e6f6ce2 100644 (file)
@@ -1215,3 +1215,21 @@ issue_3682_3: {
     }
     expect_stdout: "-Infinity"
 }
+
+issue_3684: {
+    options = {
+        evaluate: true,
+    }
+    input: {
+        console.log(1 / (-1 * (0 & console) + 0));
+        console.log(1 / ((0 & console) / -1 + 0));
+    }
+    expect: {
+        console.log(1 / (-1 * (0 & console) + 0));
+        console.log(1 / ((0 & console) / -1 + 0));
+    }
+    expect_stdout: [
+        "Infinity",
+        "Infinity",
+    ]
+}