diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-11 06:43:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 13:43:08 +0800 |
commit | 64ebf6efe939f9ea6a7b5bae8762460fdcc39ad7 (patch) | |
tree | b370d8ea736dfbb4c3fa0033cab45fc2dab84c0e | |
parent | 08391b8e1c35da8b094aa4eebe6e6b6bbf5f3019 (diff) | |
download | tracifyjs-64ebf6efe939f9ea6a7b5bae8762460fdcc39ad7.tar.gz tracifyjs-64ebf6efe939f9ea6a7b5bae8762460fdcc39ad7.zip |
fix corner case in `awaits` & `side_effects` (#5072)
fixes #5070
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/awaits.js | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index e9fe51b9..28f127d5 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -7820,6 +7820,7 @@ merge(Compressor.prototype, { 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_ForAwaitOf) return abort = true; if (node instanceof AST_Return) { if (node.value && !is_primitive(compressor, node.value)) return abort = true; return; diff --git a/test/compress/awaits.js b/test/compress/awaits.js index eb808464..dc278f7e 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -2023,3 +2023,26 @@ issue_5034: { expect_stdout: "PASS" 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" +} |