prism
prism copied to clipboard
`NoMatchingPatternError` on hash + parenthesis omission
Hey folks,
Been getting an odd NoMatchingPatternError on Ruby 3.4.3 and Prism 1.4.0 (same on latest main at 2cae3102e9dfa7b5e4c53a6d6c3c5554f6108387)
# 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
Thanks for the report! I'll check it out
I think the cause of this issue is:
Prism.parse_success? "print message: in 'BAR'" # => false
Prism.parse_success? "A.print message: in 'BAR'" # => true, should be false
Prism.parse_success? "A.print message:\nin 'BAR'" # => true, should be false
and it is not fixed yet.
You're absolutely right, I'll keep going. Thanks @tompng!