Skip to content

Commit

Permalink
fix corner case in inline (#5693)
Browse files Browse the repository at this point in the history
fixes #5692
  • Loading branch information
alexlamsl authored Oct 3, 2022
1 parent 80fc862 commit 140e4e0
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -13888,7 +13888,10 @@ Compressor.prototype.compress = function(node) {
var abort = false;
stat.walk(new TreeWalker(function(node) {
if (abort) return true;
if (async && node instanceof AST_Await || node instanceof AST_Return) return abort = true;
if (async && (node instanceof AST_Await || node instanceof AST_ForAwaitOf)
|| node instanceof AST_Return) {
return abort = true;
}
if (node instanceof AST_Scope) return true;
}));
return !abort;
Expand Down
58 changes: 58 additions & 0 deletions test/compress/awaits.js
Original file line number Diff line number Diff line change
Expand Up @@ -3540,3 +3540,61 @@ issue_5634_3_side_effects: {
]
node_version: ">=8"
}

issue_5692_1: {
options = {
awaits: true,
inline: true,
}
input: {
(async function() {
(async function() {
for await (var k of []);
})();
console.log("foo");
})();
console.log("bar");
}
expect: {
(async function() {
(async function() {
for await (var k of []);
})();
console.log("foo");
})();
console.log("bar");
}
expect_stdout: [
"foo",
"bar",
]
node_version: ">=10"
}

issue_5692_2: {
options = {
awaits: true,
inline: true,
}
input: {
(async function() {
(async function() {
for (var k of []);
})();
console.log("foo");
})();
console.log("bar");
}
expect: {
(async function() {
for (var k of []);
console.log("foo");
})();
console.log("bar");
}
expect_stdout: [
"foo",
"bar",
]
node_version: ">=8"
}
21 changes: 21 additions & 0 deletions test/compress/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8719,3 +8719,24 @@ single_use_inline_collision: {
}
expect_stdout: "PASS"
}

issue_5692: {
options = {
inline: true,
}
input: {
(function() {
while (console.log("PASS"))
if (console)
return;
})();
}
expect: {
(function() {
while (console.log("PASS"))
if (console)
return;
})();
}
expect_stdout: "PASS"
}

0 comments on commit 140e4e0

Please sign in to comment.