[Pkg-javascript-commits] [uglifyjs] 173/228: fix missing parentheses around NaN/Infinity shorthands (#1726)

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 2e41cd6394ad389080b446c20f519fc3920f81c7
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Wed Mar 29 20:53:03 2017 +0800

    fix missing parentheses around NaN/Infinity shorthands (#1726)
    
    fixes #1724
    fixes #1725
---
 lib/output.js              |  4 +++-
 test/compress/issue-597.js | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/output.js b/lib/output.js
index d71f6aa..c8c8739 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -596,7 +596,9 @@ function OutputStream(options) {
         var p = output.parent();
         return p instanceof AST_PropAccess && p.expression === this
             || p instanceof AST_Call && p.expression === this
-            || p instanceof AST_Unary && p.operator != "+" && p.operator != "-";
+            || p instanceof AST_Unary && p.operator != "+" && p.operator != "-"
+            || p instanceof AST_Binary && p.right === this
+                && (p.operator == "/" || p.operator == "%");
     });
 
     PARENS(AST_Seq, function(output){
diff --git a/test/compress/issue-597.js b/test/compress/issue-597.js
index 3a50153..2aaaf3f 100644
--- a/test/compress/issue-597.js
+++ b/test/compress/issue-597.js
@@ -107,3 +107,27 @@ beautify_on_2: {
     }
     expect_exact: "console.log(null.toString(), (void 0).toString());"
 }
+
+issue_1724: {
+    input: {
+        var a = 0;
+        ++a % Infinity | Infinity ? a++ : 0;
+        console.log(a);
+    }
+    expect: {
+        var a = 0;
+        ++a % (1/0) | 1/0 ? a++ : 0;
+        console.log(a);
+    }
+    expect_stdout: "2"
+}
+
+issue_1725: {
+    input: {
+        ([].length === 0) % Infinity ? console.log("PASS") : console.log("FAIL");
+    }
+    expect: {
+        (0 === [].length) % (1/0) ? console.log("PASS") : console.log("FAIL");
+    }
+    expect_stdout: "PASS"
+}

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