aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js3
-rw-r--r--test/compress/arguments.js79
2 files changed, 45 insertions, 37 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 07916323..adae9338 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -8322,7 +8322,8 @@ merge(Compressor.prototype, {
var argname = fn.argnames[index];
if (def.deleted && def.deleted[index]) {
argname = null;
- } else if (argname && compressor.has_directive("use strict")) {
+ } else if (argname && (compressor.has_directive("use strict")
+ || !(fn_parent instanceof AST_Call && index < fn_parent.args.length))) {
var arg_def = argname.definition();
if (!compressor.option("reduce_vars")
|| def.reassigned
diff --git a/test/compress/arguments.js b/test/compress/arguments.js
index 119eaf2c..dc00eefe 100644
--- a/test/compress/arguments.js
+++ b/test/compress/arguments.js
@@ -243,20 +243,18 @@ issue_3273: {
arguments: true,
}
input: {
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
- function f(a) {
+ (function(a) {
console.log(a, a);
a++;
console.log(a, a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",
@@ -264,26 +262,43 @@ issue_3273: {
]
}
+issue_3273_no_call_arg: {
+ options = {
+ arguments: true,
+ }
+ input: {
+ (function(a) {
+ arguments[0] = "FAIL";
+ console.log(a);
+ })();
+ }
+ expect: {
+ (function(a) {
+ arguments[0] = "FAIL";
+ console.log(a);
+ })();
+ }
+ expect_stdout: "undefined"
+}
+
issue_3273_reduce_vars: {
options = {
arguments: true,
reduce_vars: true,
}
input: {
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
- function f(a) {
+ (function(a) {
console.log(a, a);
a++;
console.log(a, a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",
@@ -296,22 +311,20 @@ issue_3273_local_strict: {
arguments: true,
}
input: {
- function f(a) {
+ (function(a) {
"use strict";
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
- function f(a) {
+ (function(a) {
"use strict";
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",
@@ -325,22 +338,20 @@ issue_3273_local_strict_reduce_vars: {
reduce_vars: true,
}
input: {
- function f(a) {
+ (function(a) {
"use strict";
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
- function f(a) {
+ (function(a) {
"use strict";
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",
@@ -354,21 +365,19 @@ issue_3273_global_strict: {
}
input: {
"use strict";
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
"use strict";
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",
@@ -383,21 +392,19 @@ issue_3273_global_strict_reduce_vars: {
}
input: {
"use strict";
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect: {
"use strict";
- function f(a) {
+ (function(a) {
console.log(arguments[0], a);
arguments[0]++;
console.log(arguments[0], a);
- }
- f(0);
+ })(0);
}
expect_stdout: [
"0 0",