Prepare for Ruby 3.4+ syntax support by introducing Prism parser#1845
Prepare for Ruby 3.4+ syntax support by introducing Prism parser#1845euglena1215 wants to merge 1 commit intosoutaro:masterfrom
Conversation
a1d711f to
7b621bf
Compare
| spec.required_ruby_version = '>= 3.2.0' | ||
|
|
||
| spec.add_runtime_dependency "parser", ">= 3.2" | ||
| spec.add_runtime_dependency "prism", ">= 0.25.0" |
There was a problem hiding this comment.
It seems that Prism::Translation::Parser33 has been available since 0.25.0.
lib/steep/source.rb
Outdated
| ::Parser::Ruby33.new(Builder.new).tap do |parser| | ||
| parser.diagnostics.all_errors_are_fatal = true | ||
| parser.diagnostics.ignore_warnings = true | ||
| if Gem::Version.new(RUBY_VERSION) <= '3.3' |
There was a problem hiding this comment.
Could you explain why this condition is necessary? It seems to me that always using Prism would make sense.
There was a problem hiding this comment.
After reviewing the prism gem, it appears that the parser in Prism::Translation is only available for Ruby 3.3 and later.
While it's debatable whether the condition to use the parser gem should be for Ruby versions less than or equal to 3.3 or simply less than 3.3, some form of conditional logic is necessary given that Steep supports Ruby 3.2.
However, this branching might not be necessary if parsing Ruby 3.2 code with Prism::Translation::Parser33 is not an issue. (It might be fine, given that all code was already being parsed by Parser::Ruby33.)
| @@ -0,0 +1,13 @@ | |||
| module Prism | |||
There was a problem hiding this comment.
The prism gem has a sig/ directory, but it was missing the Prism::Translation::Parser33 class that steep uses.
To support future Ruby syntax (3.4+), we need to migrate from the parser gem to Prism. - Use Prism::Translation::Parser33 instead of Parser::Ruby33 - Add RBS type definitions for Prism parser classes in sig/shims/ - Update test cases to work with both parsers where Prism's stricter checking caused failures, adjusting syntax while preserving original intent
|
@soutaro |
To support future Ruby syntax (3.4+), we need to migrate from the parser gem to Prism.