Rich-Harris / butternut

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

Bug: IIFE exclamation marks are incorrectly removed inside conditions #117

Closed loilo closed 7 years ago

loilo commented 7 years ago

Trying to squash minified aight failed.

The essence is that IIFEs in the form of !function() { ... }() that are evaluated as conditions will incorrectly get their exclamation mark removed by Butternut, resulting in invalid output:

function fn () {
  if ( !function () {
    return any_value
  }() ) {
    do_something()
  }
}

The invaild output is this:

function fn(){function(){return any_value}()||do_something()}
Rich-Harris commented 7 years ago

thanks, fixed — will work through the other bugs before cutting a release