From: Alex Lam S.L Date: Sat, 19 Dec 2020 04:47:46 +0000 (+0800) Subject: fix corner case in `reduce_vars` & `unused` (#4414) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9a5aede94147bf5769054fd933b1c15690915d25;p=UglifyJS.git fix corner case in `reduce_vars` & `unused` (#4414) fixes #4413 --- diff --git a/lib/scope.js b/lib/scope.js index 187309ca..fac673bc 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -257,6 +257,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { sym = self.def_global(node); } else if (name == "arguments" && sym.orig[0] instanceof AST_SymbolFunarg + && !(sym.orig[1] instanceof AST_SymbolFunarg) && !(sym.scope instanceof AST_Arrow)) { var parent = tw.parent(); if (parent instanceof AST_Assign && parent.left === node diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 1c9ab61f..d048707a 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -3134,3 +3134,22 @@ issue_4404: { } expect_stdout: "PASS" } + +issue_4413: { + options = { + reduce_vars: true, + unused: true, + } + input: { + console.log(function f(arguments) { + var arguments = function() {}; + return arguments.length; + }()); + } + expect: { + console.log(function(arguments) { + return function() {}.length; + }()); + } + expect_stdout: "0" +}