Skip to content

Commit

Permalink
fix corner case in inline (#5577)
Browse files Browse the repository at this point in the history
fixes #5576
  • Loading branch information
alexlamsl authored Jul 26, 2022
1 parent 996836b commit da930af
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions test/compress/yields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit da930af

Please sign in to comment.