Improve error message for comma after rest element in arrow func
This commit is contained in:
parent
2bc124bf49
commit
c441afeaa6
@ -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(
|
||||
|
||||
1
test/fixtures/es2015/arrow-functions/params-invalid-rest-trailing-comma/actual.js
vendored
Normal file
1
test/fixtures/es2015/arrow-functions/params-invalid-rest-trailing-comma/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(...a,) => {};
|
||||
3
test/fixtures/es2015/arrow-functions/params-invalid-rest-trailing-comma/options.json
vendored
Normal file
3
test/fixtures/es2015/arrow-functions/params-invalid-rest-trailing-comma/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "A trailing comma is not permitted after the rest element (1:5)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user