diff options
-rw-r--r-- | prism/prism.c | 4 | ||||
-rw-r--r-- | test/prism/errors/array_with_double_commas.txt | 3 | ||||
-rw-r--r-- | test/prism/errors/double_splat_with_double_commas.txt | 3 |
3 files changed, 10 insertions, 0 deletions
diff --git a/prism/prism.c b/prism/prism.c index 83b6f7e00c..567c337054 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -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); diff --git a/test/prism/errors/array_with_double_commas.txt b/test/prism/errors/array_with_double_commas.txt new file mode 100644 index 0000000000..7c971103f6 --- /dev/null +++ b/test/prism/errors/array_with_double_commas.txt @@ -0,0 +1,3 @@ +[a:1,,] + ^ unexpected ','; expected a `]` to close the array + diff --git a/test/prism/errors/double_splat_with_double_commas.txt b/test/prism/errors/double_splat_with_double_commas.txt new file mode 100644 index 0000000000..27873b7fac --- /dev/null +++ b/test/prism/errors/double_splat_with_double_commas.txt @@ -0,0 +1,3 @@ +[**a,,] + ^ unexpected ','; expected a `]` to close the array + |