Rich-Harris / butternut

The fast, future-friendly minifier
https://butternut.now.sh
MIT License
1.17k stars 17 forks source link

Body-less loop with semicolon as last line in block #38

Closed Conduitry closed 7 years ago

Conduitry commented 7 years ago

If you have a loop (for, while) that is body-less and is terminated with a semicolon (rather than braces), and it's the last line in its block, the semicolon is removed, resulting in invalid code.

function f() {
  while (g());
}

produces

function f(){while(g())}

which is invalid. REPL, although its use of check: true prevents you from actually seeing this output.

Rich-Harris commented 7 years ago

Good catch. Yeah, the check: true option should probably include the resulting broken code on the error object so we can still show the output, that's annoying

Rich-Harris commented 7 years ago

Fixed in 0.3.6, thanks