Skip to content

Commit

Permalink
fix corner case in arguments (#5007)
Browse files Browse the repository at this point in the history
fixes #5006
  • Loading branch information
alexlamsl committed Jun 15, 2021
1 parent 498ac83 commit ac1262d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -11717,7 +11717,11 @@ merge(Compressor.prototype, {
} else if (compressor.has_directive("use strict")
|| fn.name
|| fn.rest
|| !(fn_parent instanceof AST_Call && index < fn_parent.args.length)
|| !(fn_parent instanceof AST_Call
&& index < fn_parent.args.length
&& all(fn_parent.args.slice(0, index + 1), function(arg) {
return !(arg instanceof AST_Spread);
}))
|| !all(fn.argnames, function(argname) {
return argname instanceof AST_SymbolFunarg;
})) {
Expand Down
20 changes: 20 additions & 0 deletions test/compress/spreads.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,23 @@ issue_4882_3: {
]
node_version: ">=8"
}

issue_5006: {
options = {
arguments: true,
}
input: {
console.log(function(b, c) {
c = "FAIL 2";
return arguments[1];
}(...[], "FAIL 1") || "PASS");
}
expect: {
console.log(function(b, c) {
c = "FAIL 2";
return arguments[1];
}(...[], "FAIL 1") || "PASS");
}
expect_stdout: "PASS"
node_version: ">=6"
}

0 comments on commit ac1262d

Please sign in to comment.