fix corner case in arguments (#4387)

fixes #4386
This commit is contained in:
Alex Lam S.L
2020-12-17 05:51:34 +00:00
committed by GitHub
parent f68e267830
commit 75e9fd8417
2 changed files with 22 additions and 0 deletions

View File

@@ -9843,6 +9843,8 @@ merge(Compressor.prototype, {
var argname = fn.argnames[index]; var argname = fn.argnames[index];
if (def.deleted && def.deleted[index]) { if (def.deleted && def.deleted[index]) {
argname = null; argname = null;
} else if (argname instanceof AST_Destructured) {
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))) { || !(fn_parent instanceof AST_Call && index < fn_parent.args.length))) {
var arg_def = argname.definition(); var arg_def = argname.definition();

View File

@@ -1866,3 +1866,23 @@ issue_4383: {
expect_stdout: "1" expect_stdout: "1"
node_version: ">=6" node_version: ">=6"
} }
issue_4386: {
options = {
arguments: true,
}
input: {
function f({}) {
return arguments[0];
}
console.log(f("PASS"));
}
expect: {
function f({}) {
return arguments[0];
}
console.log(f("PASS"));
}
expect_stdout: "PASS"
node_version: ">=6"
}