[Pkg-javascript-commits] [uglifyjs] 144/491: compute `uses_arguments` correctly in `figure_out_scope()` (#2099)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:30 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 3f961bbba04a8cec0ab74f4a13deb4be217da877
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Thu Jun 15 03:28:26 2017 +0800

    compute `uses_arguments` correctly in `figure_out_scope()` (#2099)
    
    fixes #2097
---
 lib/scope.js               |  5 ++---
 test/compress/functions.js | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lib/scope.js b/lib/scope.js
index ea43f75..82a935a 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -197,11 +197,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
                 }
             }
             var sym = node.scope.find_variable(name);
-            if (node.scope instanceof AST_Lambda && name == "arguments") {
-                node.scope.uses_arguments = true;
-            }
             if (!sym) {
                 sym = self.def_global(node);
+            } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
+                sym.scope.uses_arguments = true;
             }
             node.thedef = sym;
             node.reference(options);
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 1359670..909a57d 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -336,3 +336,32 @@ issue_2084: {
     }
     expect_stdout: "0"
 }
+
+issue_2097: {
+    options = {
+        negate_iife: true,
+        reduce_vars: true,
+        toplevel: true,
+        unused: true,
+    }
+    input: {
+        function f() {
+            try {
+                throw 0;
+            } catch (e) {
+                console.log(arguments[0]);
+            }
+        }
+        f(1);
+    }
+    expect: {
+        !function() {
+            try {
+                throw 0;
+            } catch (e) {
+                console.log(arguments[0]);
+            }
+        }(1);
+    }
+    expect_stdout: "1"
+}

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