Rich-Harris / butternut

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

Bug: Labels and nested blocks #135

Closed loilo closed 7 years ago

loilo commented 7 years ago

From squashing minified [basis.js].

Butternut seems to have problems handling labels: in combination with if/elseand other blocks. It generates invalid semicolons after blocks.

This seems to be an unfixed edge case of #113.

Reproduction:

Example input:

if ( any_condition_1 )
  label: while ( any_condition_2 ) {
    var any_value
    any_fn_1()
    break label
  }
else any_fn_2()

Output Butternut:

if(any_condition_1)label:while(any_condition_2){var any_value;any_fn_1();break label};else any_fn_2()
//                                                                           invalid ^

Output UglifyJS:

if(any_condition_1)n:for(;any_condition_2;){var any_value;any_fn_1();break n}else any_fn_2();