Fix crash on anonymous splat in find pattern and {**nil} - #465
Merged
Conversation
Prism represents an anonymous splat as a `SplatNode` whose `expression`
is nil, so `FindPatternNode#initialize` passed nil into
`AST.create_pattern_node` and crashed with:
undefined method 'type' for nil (NoMethodError)
lib/typeprof/core/ast.rb:334:in 'AST.create_pattern_node'
lib/typeprof/core/ast/pattern.rb:61:in 'FindPatternNode#initialize'
`left` and `right` are never nil (the grammar requires both splats), so
check `expression` instead, as `ArrayPatternNode` already does for its
rest pattern.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`HashPatternNode#rest` is `AssocSplatNode | NoKeywordsParameterNode |
nil`, but the code assumed it always responds to `value`, so `in {**nil}`
crashed with:
undefined method 'value' for an instance of Prism::NoKeywordsParameterNode
lib/typeprof/core/ast/pattern.rb:42:in 'HashPatternNode#initialize'
Dispatch on the node class, mirroring `ArrayPatternNode#initialize`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ahogappa
pushed a commit
to ahogappa/ryac
that referenced
this pull request
Aug 13, 2026
ruby/typeprof#465 (merged upstream) fixes the anonymous-splat find pattern and `**nil` hash pattern crashes; #451 fixed parameterless block pipes. The blanket find-pattern guard was both too broad (NAMED splat find patterns ingest fine on 0.32.0 and now minify — corpus and pins cover them) and too narrow (`**nil` and `{ || }` crashed unguarded). The pre-scan raise is gone. update_rb_file is wrapped instead: a typeprof that ingests a shape just analyzes it; one that crashes gets the crash converted to a MinifyError naming the construct and line. The analyzer tests pin that contract for all three hazard shapes, so when the Gemfile's typeprof carries the fixes the success path activates with no further change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016BMPhxTBHdPWT7UyraSLaD
ahogappa
pushed a commit
to ahogappa/ryac
that referenced
this pull request
Aug 13, 2026
…ments The Gemfile moves typeprof to master, which carries the ingestion fixes for anonymous-splat find patterns and `**nil` (ruby/typeprof#465) and parameterless block pipes (#451); the corpus now exercises all three and the pins are regenerated under that typeprof. The gemspec still admits released 0.32.0, where the analyzer names these constructs in a MinifyError instead. alias/undef rendering goes through r_alias_name: plain symbols keep dropping the colon, and an interpolated symbol keeps its own syntax instead of crashing on a missing #value. The type-repair prose comments are cut down to the invariant they protect; narration about what the type checker does or fails to see is gone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016BMPhxTBHdPWT7UyraSLaD
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.
Two pattern-matching forms crash during AST construction on master:
Prism represents an anonymous splat as a
SplatNodewhoseexpressionisnil, andHashPatternNode#restcan be aNoKeywordsParameterNode, which has novalue. Both were passed toAST.create_pattern_nodeunchecked.ArrayPatternNodealready guards against these, so this applies the same handling toFindPatternNodeandHashPatternNode.