[ruby/prism] Reject extra comma in array after keyword argument

Fixes: https://github.com/ruby/prism/issues/3109

https://github.com/ruby/prism/commit/9ed989c30d
This commit is contained in:
ydah 2024-11-27 19:53:18 +09:00 committed by git
parent 90404ca460
commit aa77bfd13e
3 changed files with 10 additions and 0 deletions

View File

@ -10869,6 +10869,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);

View File

@ -0,0 +1,3 @@
[a:1,,]
^ unexpected ','; expected a `]` to close the array

View File

@ -0,0 +1,3 @@
[**a,,]
^ unexpected ','; expected a `]` to close the array