[Pkg-javascript-commits] [uglifyjs] 398/491: fix corner case with `arguments` as function name (#2729)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:56 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 9f23185f2bb0d23d5dd2e2334c589e97132a37a8
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Fri Jan 5 22:21:18 2018 +0800
fix corner case with `arguments` as function name (#2729)
fixes #2728
---
lib/scope.js | 2 +-
test/compress/typeof.js | 123 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+), 1 deletion(-)
diff --git a/lib/scope.js b/lib/scope.js
index 801c888..a18e92a 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -151,7 +151,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
node.references = [];
}
if (node instanceof AST_SymbolLambda) {
- defun.def_function(node, defun);
+ defun.def_function(node, node.name == "arguments" ? undefined : defun);
}
else if (node instanceof AST_SymbolDefun) {
// Careful here, the scope where this should be defined is
diff --git a/test/compress/typeof.js b/test/compress/typeof.js
index 72e77be..b5f1401 100644
--- a/test/compress/typeof.js
+++ b/test/compress/typeof.js
@@ -178,3 +178,126 @@ duplicate_lambda_arg_name: {
}
expect_stdout: "undefined"
}
+
+issue_2728_1: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ typeofs: true,
+ }
+ input: {
+ (function arguments() {
+ console.log(typeof arguments);
+ })();
+ }
+ expect: {
+ (function arguments() {
+ console.log(typeof arguments);
+ })();
+ }
+ expect_stdout: "object"
+}
+
+issue_2728_2: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ typeofs: true,
+ }
+ input: {
+ function arguments() {
+ return typeof arguments;
+ }
+ console.log(typeof arguments, arguments());
+ }
+ expect: {
+ function arguments() {
+ return typeof arguments;
+ }
+ console.log(typeof arguments, arguments());
+ }
+ expect_stdout: "function object"
+}
+
+issue_2728_3: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ typeofs: true,
+ }
+ input: {
+ (function() {
+ function arguments() {
+ }
+ console.log(typeof arguments);
+ })();
+ }
+ expect: {
+ (function() {
+ function arguments() {
+ }
+ console.log("function");
+ })();
+ }
+ expect_stdout: "function"
+}
+
+issue_2728_4: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel: true,
+ typeofs: true,
+ }
+ input: {
+ function arguments() {
+ }
+ console.log(typeof arguments);
+ }
+ expect: {
+ function arguments() {
+ }
+ console.log("function");
+ }
+ expect_stdout: "function"
+}
+
+issue_2728_5: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ typeofs: true,
+ }
+ input: {
+ (function arguments(arguments) {
+ console.log(typeof arguments);
+ })();
+ }
+ expect: {
+ (function arguments(arguments) {
+ console.log(typeof arguments);
+ })();
+ }
+ expect_stdout: "undefined"
+}
+
+issue_2728_6: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ typeofs: true,
+ }
+ input: {
+ function arguments(arguments) {
+ return typeof arguments;
+ }
+ console.log(typeof arguments, arguments());
+ }
+ expect: {
+ function arguments(arguments) {
+ return typeof arguments;
+ }
+ console.log(typeof arguments, arguments());
+ }
+ expect_stdout: "function undefined"
+}
--
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