fix corner case in inline (#4389)

fixes #4388
This commit is contained in:
Alex Lam S.L
2020-12-17 16:55:19 +00:00
committed by GitHub
parent a96f087ac3
commit 02fdcfde01
2 changed files with 23 additions and 2 deletions

View File

@@ -8026,8 +8026,14 @@ merge(Compressor.prototype, {
}));
if (found) return false;
}
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
&& (exp !== fn || fn.parent_scope.resolve() === scope);
var safe_to_inject = exp !== fn || fn.parent_scope.resolve() === scope;
if (scope instanceof AST_Toplevel) {
if (compressor.toplevel.vars) {
defined["arguments"] = true;
} else {
safe_to_inject = false;
}
}
var inline = compressor.option("inline");
var used = Object.create(defined);
if (!can_inject_args(defined, used, inline >= 2 && safe_to_inject)) return false;

View File

@@ -336,3 +336,18 @@ trim_body: {
expect_stdout: "PASS undefined"
node_version: ">=4"
}
issue_4388: {
options = {
inline: true,
toplevel: true,
}
input: {
(arguments => console.log(arguments && arguments))();
}
expect: {
(arguments => console.log(arguments && arguments))();
}
expect_stdout: "undefined"
node_version: ">=4"
}