add support for trailing commas in arrow function parameter lists - fixes #1841
This commit is contained in:
parent
030d5f7c6b
commit
84c773a7ca
@ -432,9 +432,18 @@ pp.parseParenAndDistinguishExpression = function(start, isAsync, canBeArrow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let innerStart = this.markPosition(), exprList = [], first = true
|
let innerStart = this.markPosition(), exprList = [], first = true
|
||||||
let refShorthandDefaultPos = {start: 0}, spreadStart, innerParenStart
|
let refShorthandDefaultPos = {start: 0}, spreadStart, innerParenStart, optionalCommaStart
|
||||||
while (this.type !== tt.parenR) {
|
while (this.type !== tt.parenR) {
|
||||||
first ? first = false : this.expect(tt.comma)
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
this.expect(tt.comma)
|
||||||
|
if (this.type === tt.parenR && this.options.features["es7.trailingFunctionCommas"]) {
|
||||||
|
optionalCommaStart = this.start
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.type === tt.ellipsis) {
|
if (this.type === tt.ellipsis) {
|
||||||
let spreadNodeStart = this.markPosition()
|
let spreadNodeStart = this.markPosition()
|
||||||
spreadStart = this.start
|
spreadStart = this.start
|
||||||
@ -462,6 +471,7 @@ pp.parseParenAndDistinguishExpression = function(start, isAsync, canBeArrow) {
|
|||||||
this.unexpected(this.lastTokStart)
|
this.unexpected(this.lastTokStart)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (optionalCommaStart) this.unexpected(optionalCommaStart)
|
||||||
if (spreadStart) this.unexpected(spreadStart)
|
if (spreadStart) this.unexpected(spreadStart)
|
||||||
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start)
|
if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user