Replace parser gem with prism for Witchcraft AST parsing#994
Replace parser gem with prism for Witchcraft AST parsing#994bbatsov merged 4 commits intotoptal:masterfrom
Conversation
|
Yeah, that's a reasonable idea. I'll review it more carefully soon. |
|
Master has been updated with CI fixes and compatibility changes (#998) — we now target Ruby 3.2+ and Rails 7.2+. Could you rebase this PR on top of master so CI can run properly? Thanks! |
|
This is a great change — |
|
One concern: Prism is bundled with Ruby 3.3+ but not available in Ruby 3.2, which we still support (
What do you think? Option 2 seems the most pragmatic if you want to keep the PR alive now. |
|
@bbatsov thanks for reviewing. I added a fallback to |
|
@bbatsov It would be great if this PR could be included in version 8.0 |
|
It's a bit late for Chewy 8.0, but this will land in 8.1. (hopefully soon) |
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
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:
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.