Fix NoMethodError in UniqueType#to_rbs for empty generic params - #43
Draft
apiology wants to merge 1 commit into
Draft
Fix NoMethodError in UniqueType#to_rbs for empty generic params#43apiology wants to merge 1 commit into
apiology wants to merge 1 commit into
Conversation
`all_params.first&.name` returns nil silently when a generic type
has zero params, which propagated a nil into to_rbs's caller instead
of raising - masking a case that should fall through to the general
"#{rbs_name}#{parameters_as_rbs}" rendering below. Guard on
`!all_params.empty?` and let the existing else branch handle the
empty case.
apiology
added a commit
that referenced
this pull request
Aug 3, 2026
Two follow-ups to the earlier extraction: - The per-file YARD/CollectionStyle todo exclusion was a stand-in for actually fixing the cop. Replace it with disabling the cop outright in .rubocop.yml, matching castwide#1237's fix: for nested-generic/tuple Hash key types, the cop's own long-style autocorrect produces syntax that doesn't preserve the original tuple's meaning, so there's no safe autocorrected form to converge on for those cases. - UniqueType#to_rbs's all_params.empty? nil-safety fix is an unrelated, pre-existing bug (from the original branch's own history, unrelated to parallel specs) - move it to #43.
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.
Summary
UniqueType#to_rbs's generic-type branch calledall_params.first&.name,which silently returns
nilwhen a generic type has zero params instead offalling through to the general
"#{rbs_name}#{parameters_as_rbs}"renderinga few lines below - the branch it should take for an unparameterized
generic. Guard on
!all_params.empty?so that case falls through correctly.Test plan
bundle exec rspec spec/complex_type_spec.rb spec/complex_type/unique_type_spec.rb: cleanbundle exec rubocop lib/solargraph/complex_type/unique_type.rb: cleanGenerated with Claude Code