[Pkg-javascript-commits] [uglifyjs] 137/228: fix cascade of `evaluate` optimisation (#1654)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit 32283a0def807e0a382d4a6a23cc42e99084e1dd
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Fri Mar 24 22:09:19 2017 +0800

    fix cascade of `evaluate` optimisation (#1654)
    
    Operator has changed, so break out from rest of the rules.
    
    fixes #1649
---
 lib/compress.js           |  2 ++
 test/compress/evaluate.js | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/lib/compress.js b/lib/compress.js
index 3804a93..e13985e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3292,6 +3292,7 @@ merge(Compressor.prototype, {
                         left: self.left,
                         right: self.right.expression
                     });
+                    break;
                 }
                 // -a + b => b - a
                 if (self.left instanceof AST_UnaryPrefix
@@ -3303,6 +3304,7 @@ merge(Compressor.prototype, {
                         left: self.right,
                         right: self.left.expression
                     });
+                    break;
                 }
               case "*":
                 associative = compressor.option("unsafe_math");
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index e7a6c6b..7a56205 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -789,3 +789,16 @@ unsafe_charAt_noop: {
         );
     }
 }
+
+issue_1649: {
+    options = {
+        evaluate: true,
+    }
+    input: {
+        console.log(-1 + -1);
+    }
+    expect: {
+        console.log(-2);
+    }
+    expect_stdout: "-2";
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list