fix corner case in side_effects (#4622)

fixes #4621
This commit is contained in:
Alex Lam S.L
2021-02-07 14:40:41 +00:00
committed by GitHub
parent 522cceeccf
commit c44b6399c3
2 changed files with 19 additions and 1 deletions

View File

@@ -8295,7 +8295,7 @@ merge(Compressor.prototype, {
if (has_arg_refs(argname)) return false; if (has_arg_refs(argname)) return false;
} }
return true; return true;
}); }) && !(fn.rest instanceof AST_Destructured && has_arg_refs(fn.rest));
var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor); var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
if (can_inline && stat instanceof AST_Return) { if (can_inline && stat instanceof AST_Return) {
var value = stat.value; var value = stat.value;

View File

@@ -696,3 +696,21 @@ issue_4575: {
expect_stdout: "PASS 0" expect_stdout: "PASS 0"
node_version: ">=6" node_version: ">=6"
} }
issue_4621: {
options = {
side_effects: true,
}
input: {
(function f(a, ...{
[console.log(a)]: b,
}) {})("PASS");
}
expect: {
(function f(a, ...{
[console.log(a)]: b,
}) {})("PASS");
}
expect_stdout: "PASS"
node_version: ">=6"
}