From 76eb259ea854e03929cad89abfa3599014e551af Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 15 Sep 2015 06:18:04 +0100 Subject: [PATCH] only allow identifiers as rest expressions --- packages/babylon/src/parser/lval.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/babylon/src/parser/lval.js b/packages/babylon/src/parser/lval.js index d3d4569611..07e4db70db 100644 --- a/packages/babylon/src/parser/lval.js +++ b/packages/babylon/src/parser/lval.js @@ -92,22 +92,17 @@ pp.parseSpread = function (refShorthandDefaultPos) { pp.parseRest = function () { let node = this.startNode(); this.next(); - if (this.match(tt.name) || this.match(tt.bracketL)) { - node.argument = this.parseBindingAtom(); - } else { - this.unexpected(); - } + node.argument = this.parseIdentifier(); return this.finishNode(node, "RestElement"); }; // Parses lvalue (assignable) atom. pp.parseBindingAtom = function () { - if (this.match(tt.name)) { - return this.parseIdentifier(true); - } - switch (this.state.type) { + case tt.name: + return this.parseIdentifier(true); + case tt.bracketL: let node = this.startNode(); this.next();