[Pkg-javascript-commits] [uglifyjs] 450/491: handle duplicate function declarations correctly (#2837)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:52:03 UTC 2018


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

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit 5e2cd07d6f6866b1ddae51a4c9b280d2cd527973
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Jan 23 01:28:09 2018 +0800

    handle duplicate function declarations correctly (#2837)
    
    fixes #2836
---
 lib/scope.js                 |  2 +-
 test/compress/reduce_vars.js | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/scope.js b/lib/scope.js
index af852bb..6c883c6 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -305,7 +305,7 @@ AST_Scope.DEFMETHOD("find_variable", function(name){
 
 AST_Scope.DEFMETHOD("def_function", function(symbol, init){
     var def = this.def_variable(symbol, init);
-    if (!def.init) def.init = init;
+    if (!def.init || def.init instanceof AST_Defun) def.init = init;
     this.functions.set(symbol.name, def);
     return def;
 });
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 33175d1..4009c35 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5360,3 +5360,26 @@ issue_2799_2: {
     }
     expect_stdout: "PASS"
 }
+
+issue_2836: {
+    options = {
+        reduce_vars: true,
+        toplevel: true,
+        unused: true,
+    }
+    input: {
+        function f() {
+            return "FAIL";
+        }
+        console.log(f());
+        function f() {
+            return "PASS";
+        }
+    }
+    expect: {
+        console.log(function() {
+            return "PASS";
+        }());
+    }
+    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