Use Prism for Ruby source parsing on Ruby >= 3.3#144
Open
flavorjones wants to merge 2 commits intomasterfrom
Open
Use Prism for Ruby source parsing on Ruby >= 3.3#144flavorjones wants to merge 2 commits intomasterfrom
flavorjones wants to merge 2 commits intomasterfrom
Conversation
Both ForbiddenConstantReferenceValidation and ForbiddenReopeningValidation check constant_assignments but neither had test coverage for that path.
The whitequark/parser gem does not support Ruby 3.4+ syntax and will not be updated. On Ruby 4.0 it falls back to its Ruby 3.3 parser, meaning it cannot parse new syntax like logical operators at line beginning. Prism, which is bundled with Ruby 3.3+, provides a translation layer (Prism::Translation::ParserCurrent) that is a drop-in replacement for Parser::CurrentRuby. It produces the same Parser::AST::Node objects, so CommandParser (which inherits from Parser::AST::Processor) continues to work unchanged. Two new methods on Console1984: - require_ruby_parser_dependencies: loads parser+prism on Ruby >= 3.3, or parser/current on older Rubies. Called by .command_parser.rb itself rather than requiring the supervisor to manage load ordering. - ruby_parser: returns the appropriate parser class for the running Ruby version. On older Rubies (< 3.3), everything continues to use the parser gem as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adding support for Ruby >= 4.0
Prism::Translation::ParserCurrentinstead ofParser::CurrentRubyon Ruby >= 3.3, for forward-compatibility with Ruby 4.0+parsergem as beforeConsole1984.ruby_parserandConsole1984.require_ruby_parser_dependenciesto centralize parser selection.command_parser.rbrequire its own dependencies instead of relying onSupervisorto manage load orderingCloses #131 which requested Ruby 4.0 support.
cc @jeremy