[ty] Avoid reporting overload errors for successful union variants#22688
Merged
charliermarsh merged 1 commit intomainfrom Jan 19, 2026
Merged
[ty] Avoid reporting overload errors for successful union variants#22688charliermarsh merged 1 commit intomainfrom
charliermarsh merged 1 commit intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
55f2bcf to
9fa25f8
Compare
dhruvmanila
reviewed
Jan 19, 2026
Comment on lines
+330
to
+332
| if binding.as_result().is_ok() { | ||
| continue; | ||
| } |
Member
There was a problem hiding this comment.
Should this be moved inside CallableBinding::report_diagnostics so that the other call (right above this) can also benefit?
Member
There was a problem hiding this comment.
Hmm, actually, that's not required because for a single binding (non-union type), the Bindings::report_diagnostics will only be called when there's actually an error. So, for a successful overload matching, this method won't be called in the first place.
dhruvmanila
approved these changes
Jan 19, 2026
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
no-matching-overload |
0 | 16 | 0 |
invalid-argument-type |
2 | 1 | 5 |
invalid-parameter-default |
0 | 0 | 7 |
invalid-assignment |
0 | 0 | 5 |
invalid-return-type |
0 | 0 | 4 |
unused-ignore-comment |
0 | 2 | 0 |
| Total | 2 | 19 | 21 |
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.
Summary
Consider
x: str | bytesand thenx.split(" "). Because we have a union, and at least one variant errors (bytesexpects aBuffer, not astr), we callbinding.report_diagnosticsfor each variant. For thestrvariant, it has two overloads that both match arity, but only one actually matches the signature... Somatching_overload_before_type_checkingisNone(because they both match arity), but we don't actually have an error, and we fall through toNO_MATCHING_OVERLOAD.If one variant succeeds, we should avoid reporting errors for it, even if not all variants matched.