Skip to content

Commit 9ed989c

Browse files
committed
Reject extra comma in array after keyword argument
Fixes: #3109
1 parent 93c0474 commit 9ed989c

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/prism.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10874,6 +10874,10 @@ parser_lex(pm_parser_t *parser) {
1087410874

1087510875
// ,
1087610876
case ',':
10877+
if ((parser->previous.type == PM_TOKEN_COMMA) && (parser->enclosure_nesting > 0)) {
10878+
PM_PARSER_ERR_TOKEN_FORMAT(parser, parser->current, PM_ERR_ARRAY_TERM, pm_token_type_human(parser->current.type));
10879+
}
10880+
1087710881
lex_state_set(parser, PM_LEX_STATE_BEG | PM_LEX_STATE_LABEL);
1087810882
LEX(PM_TOKEN_COMMA);
1087910883

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[a:1,,]
2+
^ unexpected ','; expected a `]` to close the array
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[**a,,]
2+
^ unexpected ','; expected a `]` to close the array
3+

0 commit comments

Comments
 (0)