Project

General

Profile

Actions

Bug #22140

open

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

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

Added by Kai (kai matsudate) 7 days ago. Updated 3 days ago.

Status:
Open
Assignee:
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-07-02T00:24:43Z master e91f477e21) +PRISM [arm64-darwin25]
[ruby-dev:<unknown>]

Description

Prism rejects the following code, while parse.y accepts it:

Prism:

$ ruby --parser=prism -ce 'while a in b, do end'
ruby: -e:1: syntax error found (SyntaxError)
> 1 | while a in b, do end
    |               ^~ expected a pattern expression after `,`

parse.y:

$ ruby --parser=parse.y -ce 'while a in b, do end'
Syntax OK

The same appears with until and for loops.

I have a draft patch here: https://github.com/ruby/prism/pull/4154

Updated by Earlopain (Earlopain _) 3 days ago Actions #1

  • Assignee set to prism
Actions

Also available in: PDF Atom