From da930affd2b9969e042dc8c9e9ded4de8f1174c2 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 26 Jul 2022 03:46:54 +0100 Subject: [PATCH] fix corner case in `inline` (#5577) fixes #5576 --- lib/compress.js | 3 ++- test/compress/yields.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 80b913813c1..b34dfca48d9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3828,7 +3828,8 @@ Compressor.prototype.compress = function(node) { var changed = false; var index = statements.length - 1; if (in_lambda && index >= 0) { - var inlined = statements[index].try_inline(compressor, block_scope); + var no_return = in_try && in_try.bfinally && in_async_generator(scope); + var inlined = statements[index].try_inline(compressor, block_scope, no_return); if (inlined) { statements[index--] = inlined; changed = true; diff --git a/test/compress/yields.js b/test/compress/yields.js index aec847bd99d..3be214e4b88 100644 --- a/test/compress/yields.js +++ b/test/compress/yields.js @@ -1701,3 +1701,37 @@ issue_5526: { ] node_version: ">=10" } + +issue_5576: { + options = { + inline: true, + } + input: { + (async function*() { + try { + (function() { + while (console.log("foo")); + })(); + } finally { + console.log("bar"); + } + })().next(); + console.log("baz"); + } + expect: { + (async function*() { + try { + while (console.log("foo")); + } finally { + console.log("bar"); + } + })().next(); + console.log("baz"); + } + expect_stdout: [ + "foo", + "bar", + "baz", + ] + node_version: ">=10" +}