But: Unknown properties of string literals / void 0 handling
loilo opened this issue · 0 comments
loilo commented
Found by trying to squash minified asciidoctor.js.
This case is really edgy and kinda weird (because I have no idea what the original code was supposed to do semantically), however it is valid JavaScript and thus should pass the squashing.
The code below actually exposes a few problems:
- Butternut seems to have an ongoing tendency to eating meaningful whitespace. :)
- Expressions replaced with
void 0
may no longer be called as functions. - As bad of a habit as this is: The
String
prototype might have been manipulated. Calling uncommon properties on string literals should not be removed.
Input:
function fn () {
return "a"[ "b" ]( c ) ? any_value_1 : any_value_2
}
Output Butternut:
function fn(){returnvoid 0(c)?any_value_1:any_value_2}
Output UglifyJS:
function fn(){return"a".b(c)?any_value_1:any_value_2}