Skip to content

Prism rejects a trailing comma in a pattern-matching loop condition before do, while parse.y accepts it#4154

Draft
kai-matsudate wants to merge 1 commit into
ruby:mainfrom
kai-matsudate:fix-pattern-loop-do-trailing-comma
Draft

Prism rejects a trailing comma in a pattern-matching loop condition before do, while parse.y accepts it#4154
kai-matsudate wants to merge 1 commit into
ruby:mainfrom
kai-matsudate:fix-pattern-loop-do-trailing-comma

Conversation

@kai-matsudate

@kai-matsudate kai-matsudate commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes Bug #22140.

Pattern matching syntax is parsed by parse_pattern. When a pattern has a trailing comma, Prism checks the token after the comma to decide whether the pattern ends there or another pattern should follow.

PM_TOKEN_KEYWORD_DO_LOOP was not included in that terminator set, so while a in b, do end were rejected even though parse.y accepts them. The same issue also applies to until and for loops.

This change treats PM_TOKEN_KEYWORD_DO_LOOP as a pattern terminator after a trailing comma, so the loop do delimiter is not parsed as the start of another pattern.

Prism rejected pattern-matching loop conditions with a trailing comma before the `do` delimiter, while parse.y accepts them.

Treat `PM_TOKEN_KEYWORD_DO_LOOP` as a terminator after a trailing comma, so the loop `do` delimiter is not parsed as another pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant