Improve error message for comma after rest element in arrow func

This commit is contained in:
Brian Ng 2017-08-24 21:28:19 -05:00
parent 2bc124bf49
commit c441afeaa6
No known key found for this signature in database
GPG Key ID: 3F2380E1E1508CA9
3 changed files with 12 additions and 0 deletions

View File

@ -911,6 +911,14 @@ export default class ExpressionParser extends LValParser {
spreadNodeStartLoc,
),
);
if (this.match(tt.comma) && this.lookahead().type === tt.parenR) {
this.raise(
this.state.start,
"A trailing comma is not permitted after the rest element",
);
}
break;
} else {
exprList.push(

View File

@ -0,0 +1 @@
(...a,) => {};

View File

@ -0,0 +1,3 @@
{
"throws": "A trailing comma is not permitted after the rest element (1:5)"
}