Skip to content

Commit

Permalink
Merge pull request #3244 from ydah/reject-exstra-comma-in-array
Browse files Browse the repository at this point in the history
Reject extra comma in array after keyword argument
  • Loading branch information
tenderlove authored Dec 2, 2024
2 parents 8d06542 + 9ed989c commit 4a14093
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -10874,6 +10874,10 @@ parser_lex(pm_parser_t *parser) {

// ,
case ',':
if ((parser->previous.type == PM_TOKEN_COMMA) && (parser->enclosure_nesting > 0)) {
PM_PARSER_ERR_TOKEN_FORMAT(parser, parser->current, PM_ERR_ARRAY_TERM, pm_token_type_human(parser->current.type));
}

lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
LEX(PM_TOKEN_COMMA);

Expand Down
3 changes: 3 additions & 0 deletions test/prism/errors/array_with_double_commas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[a:1,,]
^ unexpected ','; expected a `]` to close the array

3 changes: 3 additions & 0 deletions test/prism/errors/double_splat_with_double_commas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[**a,,]
^ unexpected ','; expected a `]` to close the array

0 comments on commit 4a14093

Please sign in to comment.