[Pkg-javascript-commits] [uglifyjs] 165/228: fix `is_number()` on `+=` (#1714)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:27 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 f71f4905b004a559f0612e0e0928204f912a66bc
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Mar 28 17:08:16 2017 +0800

    fix `is_number()` on `+=` (#1714)
    
    fixes #1710
---
 lib/compress.js          |  4 ++--
 test/compress/numbers.js | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index e4863d9..c60f863 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1167,9 +1167,9 @@ merge(Compressor.prototype, {
                 && this.left.is_number(compressor)
                 && this.right.is_number(compressor);
         });
-        var assign = makePredicate("-= *= /= %= &= |= ^= <<= >>= >>>=");
         def(AST_Assign, function(compressor){
-            return assign(this.operator) || this.right.is_number(compressor);
+            return binary(this.operator.slice(0, -1))
+                || this.operator == "=" && this.right.is_number(compressor);
         });
         def(AST_Seq, function(compressor){
             return this.cdr.is_number(compressor);
diff --git a/test/compress/numbers.js b/test/compress/numbers.js
index 0b40bb9..ea439ec 100644
--- a/test/compress/numbers.js
+++ b/test/compress/numbers.js
@@ -153,3 +153,18 @@ evaluate_4: {
         );
     }
 }
+
+issue_1710: {
+    options = {
+        evaluate: true,
+    }
+    input: {
+        var x = {};
+        console.log((x += 1) + -x);
+    }
+    expect: {
+        var x = {};
+        console.log((x += 1) + -x);
+    }
+    expect_stdout: true
+}

-- 
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