fix corner case in inline (#5367)

fixes #5366
This commit is contained in:
Alex Lam S.L
2022-02-21 03:31:29 +00:00
committed by GitHub
parent dd3b81dec6
commit 313e4974a4
2 changed files with 26 additions and 2 deletions

View File

@@ -13454,9 +13454,12 @@ Compressor.prototype.compress = function(node) {
inlined = inlined.try_inline(compressor, scope, true, in_loop);
if (inlined) {
this.init = null;
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",
]
}