[Pkg-javascript-commits] [uglifyjs] 201/228: fix `mangleProperties` on identifiers (#1776)

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 48b3fe99524e1e85edd30f0a326c2f1136e150e4
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Mon Apr 3 23:17:47 2017 +0800

    fix `mangleProperties` on identifiers (#1776)
    
    - fix handling of "-Infinity"
    - add test case for "-0"
    
    reverts #1481
---
 lib/propmangle.js           |   2 +-
 test/compress/issue-1770.js | 148 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 146 insertions(+), 4 deletions(-)

diff --git a/lib/propmangle.js b/lib/propmangle.js
index c1e8c7e..4e43bb6 100644
--- a/lib/propmangle.js
+++ b/lib/propmangle.js
@@ -47,6 +47,7 @@ function find_builtins() {
     // NaN will be included due to Number.NaN
     var a = [
         "Infinity",
+        "-Infinity",
         "undefined",
     ];
     [ Object, Array, Function, Number,
@@ -153,7 +154,6 @@ function mangle_properties(ast, options) {
     // only function declarations after this line
 
     function can_mangle(name) {
-        if (!is_identifier(name)) return false;
         if (unmangleable.indexOf(name) >= 0) return false;
         if (reserved.indexOf(name) >= 0) return false;
         if (options.only_cache) {
diff --git a/test/compress/issue-1770.js b/test/compress/issue-1770.js
index 69df896..9008c6f 100644
--- a/test/compress/issue-1770.js
+++ b/test/compress/issue-1770.js
@@ -6,6 +6,7 @@ mangle_props: {
             NaN: 2,
             Infinity: 3,
             "-Infinity": 4,
+            "-0": 5,
         };
         console.log(
             obj[void 0],
@@ -19,7 +20,10 @@ mangle_props: {
             obj["Infinity"],
             obj[-1/0],
             obj[-Infinity],
-            obj["-Infinity"]
+            obj["-Infinity"],
+            obj[-0],
+            obj[-""],
+            obj["-0"]
         );
     }
     expect: {
@@ -28,6 +32,7 @@ mangle_props: {
             NaN: 2,
             Infinity: 3,
             "-Infinity": 4,
+            a: 5,
         };
         console.log(
             obj[void 0],
@@ -41,8 +46,145 @@ mangle_props: {
             obj["Infinity"],
             obj[-1/0],
             obj[-1/0],
-            obj["-Infinity"]
+            obj["-Infinity"],
+            obj[-0],
+            obj[-""],
+            obj["a"]
         );
     }
-    expect_stdout: true
+    expect_stdout: "1 1 1 2 2 2 3 3 3 4 4 4 undefined undefined 5"
+}
+
+identifier: {
+    mangle_props = {}
+    input: {
+        var obj = {
+            abstract: 1,
+            boolean: 2,
+            byte: 3,
+            char: 4,
+            class: 5,
+            double: 6,
+            enum: 7,
+            export: 8,
+            extends: 9,
+            final: 10,
+            float: 11,
+            goto: 12,
+            implements: 13,
+            import: 14,
+            int: 15,
+            interface: 16,
+            let: 17,
+            long: 18,
+            native: 19,
+            package: 20,
+            private: 21,
+            protected: 22,
+            public: 23,
+            short: 24,
+            static: 25,
+            super: 26,
+            synchronized: 27,
+            this: 28,
+            throws: 29,
+            transient: 30,
+            volatile: 31,
+            yield: 32,
+            false: 33,
+            null: 34,
+            true: 35,
+            break: 36,
+            case: 37,
+            catch: 38,
+            const: 39,
+            continue: 40,
+            debugger: 41,
+            default: 42,
+            delete: 43,
+            do: 44,
+            else: 45,
+            finally: 46,
+            for: 47,
+            function: 48,
+            if: 49,
+            in: 50,
+            instanceof: 51,
+            new: 52,
+            return: 53,
+            switch: 54,
+            throw: 55,
+            try: 56,
+            typeof: 57,
+            var: 58,
+            void: 59,
+            while: 60,
+            with: 61,
+        };
+    }
+    expect: {
+        var obj = {
+            a: 1,
+            b: 2,
+            c: 3,
+            d: 4,
+            e: 5,
+            f: 6,
+            g: 7,
+            h: 8,
+            i: 9,
+            j: 10,
+            k: 11,
+            l: 12,
+            m: 13,
+            n: 14,
+            o: 15,
+            p: 16,
+            q: 17,
+            r: 18,
+            s: 19,
+            t: 20,
+            u: 21,
+            v: 22,
+            w: 23,
+            x: 24,
+            y: 25,
+            z: 26,
+            A: 27,
+            B: 28,
+            C: 29,
+            D: 30,
+            F: 31,
+            G: 32,
+            H: 33,
+            I: 34,
+            J: 35,
+            K: 36,
+            L: 37,
+            M: 38,
+            N: 39,
+            O: 40,
+            P: 41,
+            Q: 42,
+            R: 43,
+            S: 44,
+            T: 45,
+            U: 46,
+            V: 47,
+            W: 48,
+            X: 49,
+            Y: 50,
+            Z: 51,
+            $: 52,
+            _: 53,
+            aa: 54,
+            ba: 55,
+            ca: 56,
+            da: 57,
+            ea: 58,
+            fa: 59,
+            ga: 60,
+            ha: 61
+        };
+    }
 }

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