[Pkg-javascript-commits] [uglifyjs] 03/49: Fix mangle with option keep_fnames=true for Safari.

Jonas Smedegaard dr at jones.dk
Fri Dec 9 11:43:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit eb63fece2f48be2be5ee1090d7bb94889a12fd80
Author: kzc <zaxxon2011 at gmail.com>
Date:   Wed Jul 13 11:44:28 2016 -0400

    Fix mangle with option keep_fnames=true for Safari.
    
    Fixes: #1202
---
 lib/scope.js                |  6 +++++-
 test/compress/issue-1202.js | 52 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/lib/scope.js b/lib/scope.js
index 7ae8707..606a5a2 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -314,9 +314,13 @@ AST_Function.DEFMETHOD("next_mangled", function(options, def){
     // a function expression's argument cannot shadow the function expression's name
 
     var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
+
+    // the function's mangled_name is null when keep_fnames is true
+    var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
+
     while (true) {
         var name = AST_Lambda.prototype.next_mangled.call(this, options, def);
-        if (!(tricky_def && tricky_def.mangled_name == name))
+        if (!tricky_name || tricky_name != name)
             return name;
     }
 });
diff --git a/test/compress/issue-1202.js b/test/compress/issue-1202.js
new file mode 100644
index 0000000..136515f
--- /dev/null
+++ b/test/compress/issue-1202.js
@@ -0,0 +1,52 @@
+mangle_keep_fnames_false: {
+    options = {
+        keep_fnames : true,
+        keep_fargs  : true,
+    }
+    mangle = {
+        keep_fnames : false,
+    }
+    input: {
+        "use strict";
+        function total() {
+            return function n(a, b, c) {
+                return a + b + c;
+            };
+        }
+    }
+    expect: {
+        "use strict";
+        function total() {
+            return function t(n, r, u) {
+                return n + r + u;
+            };
+        }
+    }
+}
+
+mangle_keep_fnames_true: {
+    options = {
+        keep_fnames : true,
+        keep_fargs  : true,
+    }
+    mangle = {
+        keep_fnames : true,
+    }
+    input: {
+        "use strict";
+        function total() {
+            return function n(a, b, c) {
+                return a + b + c;
+            };
+        }
+    }
+    expect: {
+        "use strict";
+        function total() {
+            return function n(t, r, u) {
+                return t + r + u;
+            };
+        }
+    }
+}
+

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