only allow identifiers as rest expressions

This commit is contained in:
Sebastian McKenzie 2015-09-15 06:18:04 +01:00
parent bcab30e606
commit 76eb259ea8

View File

@ -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();