fix corner case in awaits & side_effects

fixes #5070
This commit is contained in:
alexlamsl 2021-07-11 12:15:43 +08:00
parent 08391b8e1c
commit 352548738e
2 changed files with 24 additions and 0 deletions

View File

@ -7820,6 +7820,7 @@ merge(Compressor.prototype, {
if (abort) return true; if (abort) return true;
if (tw.parent() === exp && node.may_throw(compressor)) return abort = true; if (tw.parent() === exp && node.may_throw(compressor)) return abort = true;
if (node instanceof AST_Await) return abort = true; if (node instanceof AST_Await) return abort = true;
if (node instanceof AST_ForAwaitOf) return abort = true;
if (node instanceof AST_Return) { if (node instanceof AST_Return) {
if (node.value && !is_primitive(compressor, node.value)) return abort = true; if (node.value && !is_primitive(compressor, node.value)) return abort = true;
return; return;

View File

@ -2023,3 +2023,26 @@ issue_5034: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8"
} }
issue_5070: {
options = {
awaits: true,
side_effects: true,
}
input: {
(async function() {
try {
for await (var a of console.log("PASS"));
} catch (e) {}
})();
}
expect: {
(async function() {
try {
for await (var a of console.log("PASS"));
} catch (e) {}
})();
}
expect_stdout: "PASS"
node_version: ">=10"
}