forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Prism work, rebase only #402
Draft
egiurleo
wants to merge
398
commits into
master
Choose a base branch
from
prism-rebased
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
Run Prism benchmarks
Run memory comparison script between Prism and Sorbet
The point of these tests is not to test Sorbet errors (yet), so making them all consistently typed false simplifies them and allows us to focus on the parse trees.
Set all prism regression test files to `# typed: false`... take 2
Fix accidental fall-through into cases for `it` keyword
Parsing the RBI gem revealed that we are not correctly translating method calls with safe navigation operators, which Sorbet represents with `CSend` nodes.
Implement Prism -> Sorbet translation for constant operator writes
Implement Prism -> Sorbet translation for assignments to method results
Handle translation of conditional send operator
Add comments to all node `case` statements
It was just there to silence a type error under `typed: true`, but since it’s now `typed: false`, we don’t need it.
Add VS Code tasks for common operations
Implement Prism -> Sorbet translation for basic pattern matching
1. It fixes the case where a hash pattern doesn't have a value, which will generate a `PM_IMPLICIT_NODE` that we currently don't handle. 2. It fixes the translation of hash patterns with a named splat node, like `in **o`.
The logic of `translateHash` was kind of confusing because it was handling both vanilla hashes and also assocs/assoc splat nodes. By isolating one part of that method, which generates key/value pairs, and then calling that method in both cases, the two code paths become cleaner and more obvious.
When the method call is `[]`, the message location should be just the begin location of `[]`.
And exclude failing tests
In cases like `foo.()`, the message would be `:call`, but the message location would have null start and end. In this case, we need to fall back to use the call operator location.
This is not covered in parse tree location tests, but reflected in symbol table tests: when we write `FOO = 1` (or other constant write nodes), the location of `FOO` should just be the name, not the entire assignment. In those cases, we should use `name_loc` instead of `base.location`.
When the symbol is used as `a: 1`, the location should not include the colon.
The main blocker for upstreaming Prism parser to Sorbet is that we currently rely on Ruby to build Prism, as its required by Prism's `rake template` task. But by package the files generated by `rake template` in Prim's release, we will be able to remove the dependency on Ruby while significantly simplify the build configurations for Prism.
When ENFORCE macros fail, they use fmt (via spdlog) to format error messages. Add a formatter specialization for pm_node_type to properly display Prism node types in these error messages. Instead of showing numeric values, the formatter uses pm_node_type_to_str to display human-readable node type names.
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.
This is a test for upstreaming our Prism work. In this PR, I've left all our commits as-is and just rebased on Prism master.
Motivation
Test plan
See included automated tests.