Rich-Harris / butternut

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

Cannot read property 'getRightHandSide' of undefined #89

Closed jbt closed 7 years ago

jbt commented 7 years ago

From the following example:

if (a) {
  if (b) {
    c;
  } else {
    // empty / comented out
  }
}

Coming from inside BlockStatement: https://github.com/Rich-Harris/butternut/blob/6f83a370a170bfd8b7793400c57bb9266e26a05f/src/program/BlockStatement.js#L112

Adding if (this.body.length === 0) return this; at the top of BlockStatement's getLeft/RightHandSide seems to fix it up fine and tests all pass, not sure whether I'm missing something though.

Rich-Harris commented 7 years ago

fixed in 0.4.4, thanks