Skip to content

Fix NoMethodError in UniqueType#to_rbs for empty generic params - #43

Draft
apiology wants to merge 1 commit into
masterfrom
fix_all_params_empty_nil_safety
Draft

Fix NoMethodError in UniqueType#to_rbs for empty generic params#43
apiology wants to merge 1 commit into
masterfrom
fix_all_params_empty_nil_safety

Conversation

@apiology

@apiology apiology commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

UniqueType#to_rbs's generic-type branch called all_params.first&.name,
which silently returns nil when a generic type has zero params instead of
falling through to the general "#{rbs_name}#{parameters_as_rbs}" rendering
a 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: clean
  • bundle exec rubocop lib/solargraph/complex_type/unique_type.rb: clean

Generated with Claude Code

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant