From a9b7b51631a35f00ca5e750f52388ad1e1af544a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 4 Aug 2026 17:25:05 -0400 Subject: [PATCH] Fix Pin::Method#== and Pin::Parameter#type_arity_decl overload bugs Both pre-existing on master, unrelated to any currently open PR: Pin::Method#== (super && other.node == node) is from castwide/solargraph#930 (2025-05-11) and never compared signatures. Pin::Parameter#type_arity_decl (arity_decl + return_type.items.count.to_s) is from castwide/solargraph#1177 (2026-05-12), the same commit that added the spec/pin/method_spec.rb "combines signatures by type" test this fix makes pass. Both bugs are dormant on plain master: GemPins.combine_method_pins_by_path, the only caller that exercises this combining logic, was itself removed by castwide/solargraph#1195 ("Limit pin combination to doc maps"), so this fix has no observable effect and no test to point to on this base until that function and its call site are restored. See PR description for context on where that currently stands. Traced from a CI-only failure on an unrelated integration-testing branch, where a different, in-progress PR stack (apiology/solargraph pin-caching-3/4) happens to re-add GemPins.combine_method_pins_by_path and its caller, waking up both of these bugs: Integer#+ inferred a return type of "Integer, BigDecimal" instead of "Integer" for `x = 0; x += 1; x`, because Pin::Method#== treated two RBS declarations of Integer#+ with different signatures (core Ruby's and the bigdecimal gem's reopening) as equal - both have nil location and identical rdoc-derived comments - so GemPins.combine_method_pins' skip-if-already-identical shortcut fired and one declaration was silently dropped instead of merged. Separately, type_arity_decl grouped signatures for merging by how many types are in each parameter's union rather than the types themselves, so distinct single-type overloads (Integer, Float, Rational, Complex, BigDecimal) bucketed together and had their return types incorrectly unioned. Fixed by comparing actual type tags in type_arity_decl and by including signatures in Pin::Method#==. --- lib/solargraph/pin/method.rb | 2 +- lib/solargraph/pin/parameter.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/pin/method.rb b/lib/solargraph/pin/method.rb index c371794e18..353d0bcf62 100644 --- a/lib/solargraph/pin/method.rb +++ b/lib/solargraph/pin/method.rb @@ -75,7 +75,7 @@ def combine_with other, attrs = {} # @param other [Pin::Method] def == other - super && other.node == node + super && other.node == node && other.signatures == signatures end def transform_types &transform diff --git a/lib/solargraph/pin/parameter.rb b/lib/solargraph/pin/parameter.rb index ba20976ec6..2726e1ab36 100644 --- a/lib/solargraph/pin/parameter.rb +++ b/lib/solargraph/pin/parameter.rb @@ -95,7 +95,7 @@ def arity_decl # @return [String] def type_arity_decl - arity_decl + return_type.items.count.to_s + arity_decl + return_type.tags end def arg?