sweet-js / sweet-core

Sweeten your JavaScript.
https://www.sweetjs.org
BSD 2-Clause "Simplified" License
4.58k stars 208 forks source link

Fix destructuring bindings #716

Open gabejohnson opened 7 years ago

gabejohnson commented 7 years ago

650 fixed issues w/ destructuring assignments in declarations. However, these forms

[...a, ] = b;
[, x, ...y,] = 0;
// and
[...{a=0},]=0;

should all throw with Uncaught SyntaxError: Rest element must be last element. The issue is w/ transformDestructuring which tries to take a SpreadElement and transform it into a RestElement.

I'd like to take the tack suggested in https://github.com/sweet-js/sweet-core/pull/650#issuecomment-288863584