DescriptionAllow trailing commas in function parameter lists
Add a flag harmony_trailing_commas_in_parameters that allows trailing
commas in function parameter declaration lists and function call
parameter lists. Trailing commas are allowed in parenthetical lists like
`(a, b, c,)` only if the next token is `=>`, thereby making it an arrow
function declaration. Only 1 trailing comma is allowed, not `(a,,)`. A
trailing comma must follow a non-rest parameter, so `(,)` and `(...a,)`
are still SyntaxErrors. However, a trailing comma is allowed after a
spread parameter, e.g. `a(...b,);`.
Add parser tests for all of the above.
BUG=v8:5051
LOG=y
Committed: https://crrev.com/1ac0965542e714d6dd9318c46199704e035f3d9b
Cr-Commit-Position: refs/heads/master@{#37355}
Patch Set 1 #
Total comments: 13
Patch Set 2 : forward flag to preparser #Patch Set 3 : more thorough testing #Patch Set 4 : update grammar comment for FormalParameters to include trailing commas #
Total comments: 4
Patch Set 5 : add tests with more than 1 parameter #
Total comments: 3
Patch Set 6 : add mjsunit test for arguments.length with trailing commas #
Total comments: 4
Patch Set 7 : rename harmony flag to just trailing_commas, omitting _in_parameters #Patch Set 8 : add test for function length with trailing commas #Patch Set 9 : rebase #
Messages
Total messages: 19 (5 generated)
|