Fix Hash#fetch generic leak from unmatched RBS interface overloads - #65
Draft
apiology wants to merge 1 commit into
Draft
Fix Hash#fetch generic leak from unmatched RBS interface overloads#65apiology wants to merge 1 commit into
apiology wants to merge 1 commit into
Conversation
Pin::Parameter#compatible_arg? rejected any argument against an RBS-interface-typed parameter (e.g. Hash#fetch's _Key) unless the argument's type was nominally included via CoreFills::INCLUDES. Since Hash#fetch's non-block, non-default overload takes a _Key-typed parameter, no overload of a plain h.fetch(k) call ever matched, and Pin::Method#return_type fell back to unioning every overload's return type together - including the unbound generic X from the two overloads that require a default value or a block. Add :allow_unmatched_interface to the rules passed to conforms_to? in compatible_arg?, matching the leniency TypeChecker itself already applies by default (see Rules#require_interfaces_resolved?) everywhere except the :alpha level. Fixes castwide#1227
apiology
added a commit
that referenced
this pull request
Aug 22, 2026
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.
This PR was written by Claude Code on behalf of @apiology.
Fixes castwide#1227
Summary
Pin::Parameter#compatible_arg?rejected every argument against an RBS-interface-typed parameter (e.g.Hash#fetch's_Key) unless the argument's type was nominally included viaCoreFills::INCLUDES. SinceHash#fetch's plain (no default, no block) overload takes a_Key-typed parameter, no overload ofh.fetch(k)ever matched during argument-type inference, andPin::Method#return_typefell back to unioning every overload's return type together — leaking the unbound genericXfrom the default-value and block overloads into the inferred type.was reported as inferring
::Integer, generic<X>against the declared::Integerreturn.Fix
Add
:allow_unmatched_interfaceto the rules passed toconforms_to?incompatible_arg?, matching the leniencyTypeCheckeralready applies by default everywhere except its:alphalevel (Rules#require_interfaces_resolved?). This is scoped to overload argument matching only —compatible_arg?has a single call site (Source::Chain::Call#inferred_pins).Test plan
spec/type_checker/levels/strong_spec.rbcoveringHash#fetch(fixed) andHash#[](control, unaffected)bundle exec rspec— 1626 examples, 0 failures, 60 pending (no new failures)bundle exec rubocopon changed files — no offenses