Project

General

Profile

Actions

Bug #21946

closed

`and?` predicate confused for leading `and` keyword

Bug #21946: `and?` predicate confused for leading `and` keyword

Added by Earlopain (Earlopain _) 1 day ago. Updated 1 day ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
[ruby-core:124935]

Description

Originally reported at https://github.com/ruby/prism/pull/3337#issuecomment-4004880188

$ ruby -ce $'foo\nand?'
ruby: -e:2: syntax errors found (SyntaxError)
  1 | foo
> 2 | and?
    |    ^ expected an expression after `?` in the ternary operator
    |    ^ unexpected '?'; expected an expression after the operator
    |     ^ unexpected end-of-input, assuming it is closing the parent ternary expression

Same for and! and or . parse.y is not impacted

Fix in https://github.com/ruby/prism/pull/3966

Actions

Also available in: PDF Atom