Skip to content

Commit

Permalink
fix corner case in inline (#5367)
Browse files Browse the repository at this point in the history
fixes #5366
  • Loading branch information
alexlamsl committed Feb 21, 2022
1 parent dd3b81d commit 313e497
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/compress.js
Expand Up @@ -13454,8 +13454,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;
Expand Down
21 changes: 21 additions & 0 deletions test/compress/functions.js
Expand Up @@ -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",
]
}

0 comments on commit 313e497

Please sign in to comment.