bublejs / buble

https://buble.surge.sh
MIT License
871 stars 67 forks source link

Array spread breaks ternaries due to not parenthesising them #177

Closed chris-morgan closed 5 years ago

chris-morgan commented 5 years ago

Minimal test case:

[...a ? b : c, d]

Result:

a ? b : c.concat( [d])

Expected:

(a ? b : c).concat( [d])

These two are wildly different!

The workaround is manual parenthesisation:

[...(a ? b : c), d]

Given that you can only spread iterables in array spread, I think ternaries are the only realistic situation where this will matter. (Well, I guess strings could wreck it too—...a + b—but #166 shows spreading strings is broken anyway.)