[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:
parent
90404ca460
commit
aa77bfd13e
@ -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);
|
||||
|
||||
|
3
test/prism/errors/array_with_double_commas.txt
Normal file
3
test/prism/errors/array_with_double_commas.txt
Normal file
@ -0,0 +1,3 @@
|
||||
[a:1,,]
|
||||
^ unexpected ','; expected a `]` to close the array
|
||||
|
3
test/prism/errors/double_splat_with_double_commas.txt
Normal file
3
test/prism/errors/double_splat_with_double_commas.txt
Normal file
@ -0,0 +1,3 @@
|
||||
[**a,,]
|
||||
^ unexpected ','; expected a `]` to close the array
|
||||
|
Loading…
x
Reference in New Issue
Block a user