[Pkg-javascript-commits] [uglifyjs] 199/228: fix mangleProperties of `undefined` & `Infinity` (#1772)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:30 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 59a4e56bc81ce96b3ee81ad4f068cfc7d89a4790
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Mon Apr 3 12:31:05 2017 +0800

    fix mangleProperties of `undefined` & `Infinity` (#1772)
    
    `NaN` already works by the happy accident of `Number.NaN`
    
    fixes #1770
---
 lib/propmangle.js           |  6 +++++-
 test/compress/issue-1770.js | 48 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/lib/propmangle.js b/lib/propmangle.js
index cfa035d..c1e8c7e 100644
--- a/lib/propmangle.js
+++ b/lib/propmangle.js
@@ -44,7 +44,11 @@
 "use strict";
 
 function find_builtins() {
-    var a = [];
+    // NaN will be included due to Number.NaN
+    var a = [
+        "Infinity",
+        "undefined",
+    ];
     [ Object, Array, Function, Number,
       String, Boolean, Error, Math,
       Date, RegExp
diff --git a/test/compress/issue-1770.js b/test/compress/issue-1770.js
new file mode 100644
index 0000000..69df896
--- /dev/null
+++ b/test/compress/issue-1770.js
@@ -0,0 +1,48 @@
+mangle_props: {
+    mangle_props = {}
+    input: {
+        var obj = {
+            undefined: 1,
+            NaN: 2,
+            Infinity: 3,
+            "-Infinity": 4,
+        };
+        console.log(
+            obj[void 0],
+            obj[undefined],
+            obj["undefined"],
+            obj[0/0],
+            obj[NaN],
+            obj["NaN"],
+            obj[1/0],
+            obj[Infinity],
+            obj["Infinity"],
+            obj[-1/0],
+            obj[-Infinity],
+            obj["-Infinity"]
+        );
+    }
+    expect: {
+        var obj = {
+            undefined: 1,
+            NaN: 2,
+            Infinity: 3,
+            "-Infinity": 4,
+        };
+        console.log(
+            obj[void 0],
+            obj[void 0],
+            obj["undefined"],
+            obj[0/0],
+            obj[NaN],
+            obj["NaN"],
+            obj[1/0],
+            obj[1/0],
+            obj["Infinity"],
+            obj[-1/0],
+            obj[-1/0],
+            obj["-Infinity"]
+        );
+    }
+    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