Skip to content

Commit 3020fe9

Browse files
committed
[Bug #21345] Fix accepting multiple rest patterns with leading match
Related: * https://bugs.ruby-lang.org/issues/20765 * #2915
1 parent 5202e5f commit 3020fe9

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17675,7 +17675,7 @@ parse_pattern(pm_parser_t *parser, pm_constant_id_list_t *captures, uint8_t flag
1767517675
// Gather up all of the patterns into the list.
1767617676
while (accept1(parser, PM_TOKEN_COMMA)) {
1767717677
// Break early here in case we have a trailing comma.
17678-
if (match9(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_SEMICOLON, PM_TOKEN_NEWLINE, PM_TOKEN_EOF,PM_TOKEN_KEYWORD_AND, PM_TOKEN_KEYWORD_OR)) {
17678+
if (match7(parser, PM_TOKEN_KEYWORD_THEN, PM_TOKEN_BRACE_RIGHT, PM_TOKEN_BRACKET_RIGHT, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_SEMICOLON, PM_TOKEN_KEYWORD_AND, PM_TOKEN_KEYWORD_OR)) {
1767917679
node = (pm_node_t *) pm_implicit_rest_node_create(parser, &parser->previous);
1768017680
pm_node_list_append(&nodes, node);
1768117681
trailing_rest = true;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a=>b, *,
2+
^ expected a pattern expression after `,`
3+

0 commit comments

Comments
 (0)