From 4d869c43633c283dd29387126e22123ebb59032a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 2 Aug 2026 21:41:04 -0400 Subject: [PATCH] Fix NoMethodError in UniqueType#to_rbs for empty generic params `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. --- lib/solargraph/complex_type/unique_type.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/complex_type/unique_type.rb b/lib/solargraph/complex_type/unique_type.rb index 4bbdda5b2..d5f67ae9f 100644 --- a/lib/solargraph/complex_type/unique_type.rb +++ b/lib/solargraph/complex_type/unique_type.rb @@ -302,7 +302,6 @@ def desc rooted_tags end - # @sg-ignore Need better if/elseanalysis # @return [String] def to_rbs if duck_type? @@ -311,8 +310,9 @@ def to_rbs 'bool' elsif name.downcase == 'nil' 'nil' - elsif name == GENERIC_TAG_NAME - all_params.first&.name + elsif name == GENERIC_TAG_NAME && !all_params.empty? + # @sg-ignore flow sensitive typing should be able to handle !empty? narrowing first to non-nil + all_params.first.name elsif %w[Class Module].include?(name) rbs_name elsif %w[Tuple Array].include?(name) && fixed_parameters?