fix corner case in inline

fixes #5366
This commit is contained in:
alexlamsl 2022-02-21 09:52:07 +08:00
parent d5afe16bc8
commit 9fcf47312c
2 changed files with 26 additions and 2 deletions

View File

@ -13393,8 +13393,11 @@ Compressor.prototype.compress = function(node) {
inlined = inlined.try_inline(compressor, scope, true, in_loop);
if (inlined) {
this.init = null;
inlined.body.push(this);
return inlined;
if (inlined instanceof AST_BlockStatement) {
inlined.body.push(this);
return inlined;
}
return make_node(AST_BlockStatement, inlined, { body: [ inlined, this ] });
}
}
return body && this;

View File

@ -8207,3 +8207,24 @@ issue_5332_2: {
}
expect_stdout: "NaN"
}
issue_5366: {
options = {
inline: true,
}
input: {
for (console.log("foo") || function() {
while (console.log("bar"));
}(); console.log("baz") ;);
}
expect: {
if (!console.log("foo"))
while (console.log("bar"));
for (;console.log("baz"););
}
expect_stdout: [
"foo",
"bar",
"baz",
]
}