Skip to content

Commit

Permalink
fix corner case in inline (#4818)
Browse files Browse the repository at this point in the history
fixes #4817
  • Loading branch information
alexlamsl committed Mar 23, 2021
1 parent e7be38b commit 78e3936
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -8787,7 +8787,7 @@ merge(Compressor.prototype, {
var can_inline = can_drop && compressor.option("inline") && !self.is_expr_pure(compressor);
if (can_inline && stat instanceof AST_Return) {
var value = stat.value;
if (exp === fn && (!value || value.is_constant_expression()) && safe_from_await_yield(fn)) {
if (exp === fn && !fn.name && (!value || value.is_constant_expression()) && safe_from_await_yield(fn)) {
return make_sequence(self, convert_args(value)).optimize(compressor);
}
}
Expand Down
20 changes: 20 additions & 0 deletions test/compress/default-values.js
Expand Up @@ -1661,3 +1661,23 @@ issue_4588_2_evaluate: {
expect_stdout: "1"
node_version: ">=6"
}

issue_4817: {
options = {
ie8: true,
inline: true,
unused: true,
}
input: {
(function f(a = console.log(typeof f)) {
return 42;
})();
}
expect: {
(function f(a = console.log(typeof f)) {
return 42;
})();
}
expect_stdout: "function"
node_version: ">=6"
}

0 comments on commit 78e3936

Please sign in to comment.