fix corner cases with yield (#4771)

fixes #4769
This commit is contained in:
Alex Lam S.L
2021-03-13 20:39:30 +00:00
committed by GitHub
parent 241113200e
commit 73e6b2550b
2 changed files with 43 additions and 2 deletions

View File

@@ -8735,7 +8735,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(value))) {
if (exp === fn && (!value || value.is_constant_expression()) && safe_from_await_yield(fn)) {
return make_sequence(self, convert_args(value)).optimize(compressor);
}
}
@@ -8803,7 +8803,8 @@ merge(Compressor.prototype, {
&& can_drop
&& all(fn.body, is_empty)
&& (fn === exp ? fn_name_unused(fn, compressor) : !has_default && !has_destructured && !fn.rest)
&& !(is_arrow(fn) && fn.value)) {
&& !(is_arrow(fn) && fn.value)
&& safe_from_await_yield(fn)) {
return make_sequence(self, convert_args()).optimize(compressor);
}
}