Skip to content

Keep Integer arithmetic Integer when an operand is untyped - #546

Draft
apiology wants to merge 1 commit into
masterfrom
skip-gem-overloads-for-untyped-arguments
Draft

apiology wants to merge 1 commit into
masterfrom
skip-gem-overloads-for-untyped-arguments

Conversation

@apiology

Copy link
Copy Markdown
Owner

Claude: This PR was written by Claude Code on behalf of @apiology.

Problem: Subtracting an untyped value from an Integer infers BigDecimal:

# with the bigdecimal gem's RBS loaded
# x infers BigDecimal, not Integer
x = 1 - unknown_method

Any Integer arithmetic on a value Solargraph cannot type becomes BigDecimal when bigdecimal is in the bundle, so strong typecheck reports false return and argument type errors downstream.

Solution: When an argument has no inferred type, overload selection uses only the method's own declaration and ignores the overloads gems add with ..., so an unknown argument no longer picks the first gem overload by position.

Since overloads an RBS `def m: ... | ...` adds are merged ahead of the
declaration they reopen, an argument whose type is unknown matched the
first added overload. With the bigdecimal RBS loaded, `n - x` on an
Integer inferred BigDecimal whenever x was untyped. When any argument
has no inferred type, match against the reopened declaration alone.
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