Skip to content

Commit

Permalink
Clarify that parseRest is always binding
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed May 19, 2017
1 parent d8769e8 commit 7c8af7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ pp.parseParenAndDistinguishExpression = function(canBeArrow) {
break
} else if (this.type === tt.ellipsis) {
spreadStart = this.start
exprList.push(this.parseParenItem(this.parseRest(true)))
exprList.push(this.parseParenItem(this.parseRestBinding()))
if (this.type === tt.comma) this.raise(this.start, "Comma is not permitted after the rest element")
break
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/lval.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ pp.parseSpread = function(refDestructuringErrors) {
return this.finishNode(node, "SpreadElement")
}

pp.parseRest = function(isBinding) {
pp.parseRestBinding = function() {
let node = this.startNode()
this.next()

// RestElement inside of a function parameter must be an identifier
if (this.options.ecmaVersion === 6 && isBinding && this.type !== tt.name)
if (this.options.ecmaVersion === 6 && this.type !== tt.name)
this.unexpected()

node.argument = this.parseBindingAtom()
Expand Down Expand Up @@ -140,7 +140,7 @@ pp.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
} else if (allowTrailingComma && this.afterTrailingComma(close)) {
break
} else if (this.type === tt.ellipsis) {
let rest = this.parseRest(true)
let rest = this.parseRestBinding()
this.parseBindingListItem(rest)
elts.push(rest)
if (this.type === tt.comma) this.raise(this.start, "Comma is not permitted after the rest element")
Expand Down

0 comments on commit 7c8af7e

Please sign in to comment.