prism
prism copied to clipboard
Parse error on pattern expression with a quoted symbol in it
System configuration
I've tried different combinations of ruby/prism versions, picked the most recent for an example
$ ruby --version
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
$ ruby -r prism -e 'p Prism::VERSION'
"0.24.0"
Steps to reproduce
here's a simplified example
code = <<~RUBY
response = { status: 'ok', '3ds_status': 'redirect', url: 'url' }
case response
in { status: 'ok', '3ds_status': 'redirect', url: url }
redirect_to url
in { status: 'ok' }
status :ok
end
RUBY
Current behavior
prism is unable to parse quoted symbol in pattern matching expression
require 'prism'
Prism.parse(code).errors
# => [#<Prism::ParseError @message="expected a label after the `,` in the hash pattern" @location=#<Prism::Location @start_offset=99 @length=0 start_line=4> @level=:fatal>]
Expected behavior
prism has to parse this expression correctly, the same code works with current parser with no problems
require 'parser/current'
Parser::CurrentRuby.parse(code) # no errors