fix corner cases in awaits (#4976)

fixes #4974
fixes #4975
This commit is contained in:
Alex Lam S.L
2021-05-28 18:47:54 +01:00
committed by GitHub
parent d320a6cde2
commit d40631fd44
2 changed files with 46 additions and 2 deletions

View File

@@ -7573,16 +7573,16 @@ merge(Compressor.prototype, {
}
return node;
});
var abort = arrow && exp.value && !is_primitive(compressor, exp.value);
var abort = !drop_body && exp.name || arrow && exp.value && !is_primitive(compressor, exp.value);
var tw = new TreeWalker(function(node) {
if (abort) return true;
if (tw.parent() === exp && node.may_throw(compressor)) return abort = true;
if (node instanceof AST_Await) return abort = true;
if (node instanceof AST_Return) {
if (node.value && !is_primitive(compressor, node.value)) return abort = true;
return;
}
if (node instanceof AST_Scope && node !== exp) return true;
if (tw.parent() === exp && node.may_throw(compressor)) return abort = true;
});
exp.walk(tw);
if (!abort) {