aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-18 02:12:01 +0000
committerGitHub <noreply@github.com>2020-12-18 10:12:01 +0800
commit1b646d3bc4bd69cbe12fb14def7716edde01a3c4 (patch)
treea90303e6c683dec344cf052f2ddc0c8e64b56c67
parent82d2aa4acf1eea742a3b1041223a74b5960d4bfd (diff)
downloadtracifyjs-1b646d3bc4bd69cbe12fb14def7716edde01a3c4.tar.gz
tracifyjs-1b646d3bc4bd69cbe12fb14def7716edde01a3c4.zip
fix corner case in `arguments` (#4400)
fixes #4399
-rw-r--r--lib/ast.js2
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/destructured.js22
3 files changed, 24 insertions, 1 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 87d578fc..fcbfb710 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -1314,7 +1314,7 @@ var AST_Label = DEFNODE("Label", "references", {
}
}, AST_Symbol);
-var AST_SymbolRef = DEFNODE("SymbolRef", "fixed", {
+var AST_SymbolRef = DEFNODE("SymbolRef", "fixed in_arg", {
$documentation: "Reference to some symbol (not definition/declaration)",
}, AST_Symbol);
diff --git a/lib/compress.js b/lib/compress.js
index 8d41ab82..33d8cf55 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -9881,6 +9881,7 @@ merge(Compressor.prototype, {
if (compressor.option("arguments")
&& expr instanceof AST_SymbolRef
&& is_arguments(def = expr.definition())
+ && !expr.in_arg
&& prop instanceof AST_Number
&& (fn = def.scope) === find_lambda()
&& fn.uses_arguments < (assigned ? 2 : 3)) {
diff --git a/test/compress/destructured.js b/test/compress/destructured.js
index 1c448f2a..8e1cf68c 100644
--- a/test/compress/destructured.js
+++ b/test/compress/destructured.js
@@ -1906,3 +1906,25 @@ issue_4395: {
expect_stdout: "PASS"
node_version: ">=6"
}
+
+issue_4399: {
+ options = {
+ arguments: true,
+ }
+ input: {
+ console.log(function({
+ [arguments[1]]: a,
+ }, b) {
+ return a;
+ }([ "PASS" ], 0));
+ }
+ expect: {
+ console.log(function({
+ [arguments[1]]: a,
+ }, b) {
+ return a;
+ }([ "PASS" ], 0));
+ }
+ expect_stdout: "PASS"
+ node_version: ">=6"
+}