Skip to content

NoMatchingPatternError on hash + parenthesis omission #3558

@avlazarov

Description

@avlazarov

Hey folks,

Been getting an odd NoMatchingPatternError on Ruby 3.4.3 and Prism 1.4.0 (same on latest main at 2cae310)

# script.rb
module A
  extend self

  def print(message:)
    puts message
  end
end

case ENV['COND']
in 'FOO'
  message = 'foo'

  A.print message:
in 'BAR'
  message = 'bar'

  A.print message:
end
→ RUBYOPT="--parser prism" COND="BAR" ruby script.rb
script.rb:13:in '<main>': "BAR": "FOO" === "BAR" does not return true (NoMatchingPatternError)

Additionally, matching both conditions

→ RUBYOPT="--parser prism" COND="FOO" ruby script.rb
foo
bar

No issues with parse.y

→ RUBYOPT="--parser parse.y" COND="BAR" ruby script.rb
bar
→ RUBYOPT="--parser parse.y" COND="FOO" ruby script.rb
foo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions