[Pkg-javascript-commits] [uglifyjs] 13/228: fix crash in unsafe replacement of undefined remove extraneous call to AST_SymbolRef.reference()

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:12 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 11676f9d72e667ea14ce380ed448da948e79f85e
Author: alexlamsl <alexlamsl at gmail.com>
Date:   Sat Feb 18 18:58:23 2017 +0800

    fix crash in unsafe replacement of undefined
    remove extraneous call to AST_SymbolRef.reference()
    
    closes #1443
---
 lib/compress.js             |  4 +--
 test/compress/issue-1443.js | 69 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index 04aa107..a15206e 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2721,13 +2721,11 @@ merge(Compressor.prototype, {
             var scope = compressor.find_parent(AST_Scope);
             var undef = scope.find_variable("undefined");
             if (undef) {
-                var ref = make_node(AST_SymbolRef, self, {
+                return make_node(AST_SymbolRef, self, {
                     name   : "undefined",
                     scope  : scope,
                     thedef : undef
                 });
-                ref.reference();
-                return ref;
             }
         }
         return self;
diff --git a/test/compress/issue-1443.js b/test/compress/issue-1443.js
new file mode 100644
index 0000000..a256587
--- /dev/null
+++ b/test/compress/issue-1443.js
@@ -0,0 +1,69 @@
+// tests assume that variable `undefined` not redefined and has `void 0` as value
+
+unsafe_undefined: {
+    options = {
+        if_return: true,
+        unsafe: true
+    }
+    mangle = {}
+    input: {
+        function f(undefined) {
+            return function() {
+                if (a)
+                    return b;
+                if (c)
+                    return d;
+            };
+        }
+    }
+    expect: {
+        function f(n) {
+            return function() {
+                if (a)
+                    return b;
+                if (c)
+                    return d;
+                else
+                    return n;
+            };
+        }
+    }
+}
+
+keep_fnames: {
+    options = {
+        if_return: true,
+        unsafe: true
+    }
+    mangle = {
+        keep_fnames: true
+    }
+    input: {
+        function f(undefined) {
+            return function() {
+                function n(a) {
+                    return a * a;
+                }
+                if (a)
+                    return b;
+                if (c)
+                    return d;
+            };
+        }
+    }
+    expect: {
+        function f(r) {
+            return function() {
+                function n(n) {
+                    return n * n;
+                }
+                if (a)
+                    return b;
+                if (c)
+                    return d;
+                else
+                    return r;
+            };
+        }
+    }
+}

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