Fix rest parameters with array and objects (#424)

* Fix rest parameters with array and objects

* Add test for array rest  with object

* reuse parseBindingIdentifier
This commit is contained in:
Brian Ng
2017-04-03 15:27:43 -05:00
committed by Daniel Tschinder
parent 22741a8068
commit 14b7f50e51
115 changed files with 10555 additions and 58 deletions

View File

@@ -110,7 +110,7 @@ pp.parseSpread = function (refShorthandDefaultPos) {
pp.parseRest = function () {
const node = this.startNode();
this.next();
node.argument = this.parseBindingIdentifier();
node.argument = this.parseBindingAtom();
return this.finishNode(node, "RestElement");
};
@@ -123,14 +123,11 @@ pp.parseBindingIdentifier = function () {
};
// Parses lvalue (assignable) atom.
pp.parseBindingAtom = function () {
switch (this.state.type) {
case tt._yield:
if (this.state.strict || this.state.inGenerator) this.unexpected();
// fall-through
case tt.name:
return this.parseIdentifier(true);
return this.parseBindingIdentifier();
case tt.bracketL:
const node = this.startNode();