Port prototype rb generation to prism - #3140
Open
Earlopain wants to merge 4 commits into
Open
Conversation
Apart from porting to prism, this also does the following: 1. Remove `variable` tracking for `type_of0`. It contains `AST::TypeParam` but checked for inclusion of a Symbol. There's no difference in the output even when this is fixed, so I just removed it entirely 2. Have the parse method return declarations, make it a class method. Just more convenient with the new structure. Eventually `rb prototype` will do this as well 3. Allow to use it on jruby/truffleruby. 4. Split comment parsing from comment processing in the helper. In rbi the comments now come from a plain parse. When `prototype rb` uses prism as well, `parse_comments` can be removed (as well as most of the other helper methods there) I tested this against code samples from https://github.com/Shopify/tapioca/blob/d029cc9c3f76865f61fdbaff68d75e18a0014764/spec/tapioca/gem/pipeline_spec.rb The output is largely the same, and improved in some areas. For example, `type_member` with no paren is no longer considered an untyped constant. Previously that was only the case for `type_member()` or when an argument was passed like `type_member(:out)`.
Earlopain
force-pushed
the
prototype-rb-prism
branch
2 times, most recently
from
August 31, 2026 12:35
94d8a02 to
832eac2
Compare
Open
This just leaves the runtime on rubyvm, which is deprecated and I won't port. Because of that, some helper methods are duplicated to work with both prism and rubyvm. I tested this on rails, and out of 3435 files only 28 differ. That is mainly for string literals that are divided by line continutions (previously they were embeded, now it's only saying it a string) Also some block optionality is changed for the better. For example `(callable || block || :itself.to_proc).call` now makes the block optional
The rubyvm code only handled `LIST` but should have checked `ZLIST` as well. As such the type was untyped previously
For the first case it resovled to untyped For the second case, it was `Array | untyped` In both cases we know it will return an array
Earlopain
force-pushed
the
prototype-rb-prism
branch
from
August 31, 2026 12:50
832eac2 to
8351f27
Compare
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.
On top of #3105
This just leaves the runtime on rubyvm, which is deprecated and I won't port.
Because of that, some helper methods are duplicated to work with both prism and rubyvm.
I tested this on rails, and out of 3435 files only 28 differ. That is mainly for string literals that are divided
by line continutions (previously they were embeded, now it's only saying it is a string)
Also some block optionality is changed for the better. For example
(callable || block || :itself.to_proc).callnow makes the block optional.Actually, rbs generation previously crashed when run against rails. Now it doesn't (:
The other two commits are fixes for things I noticed along the way. They result in many (correct) changes in rbs compared to the current imlpementation, so I separated them so it's easier to compare.