Fix crash on empty parentheses () in AST conversion#441
Merged
mame merged 1 commit intoruby:masterfrom Apr 28, 2026
Merged
Conversation
`AST.create_node` unwraps `:parentheses_node` by assigning `raw_node = raw_node.body`, but for `()` the body is nil, causing a NoMethodError on the subsequent `raw_node.type` dispatch. Return `DummyNilNode` when the body is nil, following the existing convention for empty syntactic slots that evaluate to nil. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
I think it's a good change. It might also be worth testing a couple more AST paths where
Separate issue: This is unrelated to this PR, but it's worth addressing as a separate issue. |
mame
approved these changes
Apr 28, 2026
Member
mame
left a comment
There was a problem hiding this comment.
Good catch! DummyNilNode has gradually been pulled into more places than I originally intended, so I should probably revisit its design at some point. That said, returning it here is much better than crashing, so I'll go ahead and merge this. Thanks for the fix!
3 tasks
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.
Problem
TypeProf::Core::AST.create_nodecrashes withNoMethodErroron the empty parentheses expression():