Skip to content

Prepare for Ruby 3.4+ syntax support by introducing Prism parser#1845

Open
euglena1215 wants to merge 1 commit intosoutaro:masterfrom
euglena1215:use-prism
Open

Prepare for Ruby 3.4+ syntax support by introducing Prism parser#1845
euglena1215 wants to merge 1 commit intosoutaro:masterfrom
euglena1215:use-prism

Conversation

@euglena1215
Copy link
Contributor

@euglena1215 euglena1215 commented Sep 16, 2025

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

spec.required_ruby_version = '>= 3.2.0'

spec.add_runtime_dependency "parser", ">= 3.2"
spec.add_runtime_dependency "prism", ">= 0.25.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that Prism::Translation::Parser33 has been available since 0.25.0.

@ParadoxV5
Copy link
Contributor

This sounds like it fixes #1450, which means it competes with AI’s #1725.

::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'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why this condition is necessary? It seems to me that always using Prism would make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@euglena1215
Copy link
Contributor Author

@soutaro
I have fixed the points you pointed out. Could you please review it again?

@euglena1215 euglena1215 requested a review from soutaro October 3, 2025 15:23
@soutaro soutaro added this to the Steep 2.0 milestone Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants