Rich-Harris / butternut

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

Bug: Combinations of braceless if and switch blocks are not handled correctly #113

Closed loilo closed 7 years ago

loilo commented 7 years ago

Squashing the minified Ace Editor failed.

Butternut did not handle the following minimal situation correctly:

if ( any_condition )
  switch ( any_value ) {
    case '':
  }
else {
  do_something()
}

This generates the following output:

if(any_condition)switch(any_value){case '':};else do_something()

The problem is, that the semi-colon after the switch block is in fact invalid syntax.

For reference: UglifyJS just does not insert the semi-colon, that's it.

Rich-Harris commented 7 years ago

Thanks — this was fixed by https://github.com/Rich-Harris/butternut/commit/0fdfa3fb42298c9edc6be601cdc166a0ccb12efd , release soon