Skip to content

Commit da930af

Browse files
authored
fix corner case in inline (#5577)
fixes #5576
1 parent 996836b commit da930af

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Diff for: lib/compress.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3828,7 +3828,8 @@ Compressor.prototype.compress = function(node) {
38283828
var changed = false;
38293829
var index = statements.length - 1;
38303830
if (in_lambda && index >= 0) {
3831-
var inlined = statements[index].try_inline(compressor, block_scope);
3831+
var no_return = in_try && in_try.bfinally && in_async_generator(scope);
3832+
var inlined = statements[index].try_inline(compressor, block_scope, no_return);
38323833
if (inlined) {
38333834
statements[index--] = inlined;
38343835
changed = true;

Diff for: test/compress/yields.js

+34
Original file line numberDiff line numberDiff line change
@@ -1701,3 +1701,37 @@ issue_5526: {
17011701
]
17021702
node_version: ">=10"
17031703
}
1704+
1705+
issue_5576: {
1706+
options = {
1707+
inline: true,
1708+
}
1709+
input: {
1710+
(async function*() {
1711+
try {
1712+
(function() {
1713+
while (console.log("foo"));
1714+
})();
1715+
} finally {
1716+
console.log("bar");
1717+
}
1718+
})().next();
1719+
console.log("baz");
1720+
}
1721+
expect: {
1722+
(async function*() {
1723+
try {
1724+
while (console.log("foo"));
1725+
} finally {
1726+
console.log("bar");
1727+
}
1728+
})().next();
1729+
console.log("baz");
1730+
}
1731+
expect_stdout: [
1732+
"foo",
1733+
"bar",
1734+
"baz",
1735+
]
1736+
node_version: ">=10"
1737+
}

0 commit comments

Comments
 (0)