Skip to content

Conversation

@t6n
Copy link

@t6n t6n commented Jan 15, 2026

Description

Motivation

The parser gem only supports Ruby syntax up to version 3.3 and will not receive updates for Ruby 3.4+. Starting with Ruby 3.4, Prism is the
official parser built into Ruby itself and is the recommended tool for all AST-related operations going forward.

This change future-proofs the Witchcraft feature by switching to Prism before parser becomes incompatible with newer Ruby versions.

Changes

  • Replace require 'parser/current' with require 'prism'
  • Use Prism::Translation::ParserCurrent.parse instead of Parser::CurrentRuby.parse
  • Update check_requirements! to check for the Prism constant instead of Parser

Technical Notes

Prism provides a translation layer (Prism::Translation::ParserCurrent) that produces Parser::AST::Node objects identical to those from the parser
gem. This means:

  • All existing AST transformation methods continue to work unchanged
  • unparser remains fully compatible since it receives the same node types
  • No changes required to the AST manipulation logic (replace_lvar, replace_send, replace_self, etc.)

Dependencies

The Witchcraft feature now requires prism instead of parser as a direct dependency. Note that unparser still has parser as a transitive
dependency for its AST node classes, but this is handled internally and does not affect Chewy's public API.

@t6n t6n requested a review from a team as a code owner January 15, 2026 11:31
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.

1 participant