Overlapping overload error changes depending on type name
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
This [discussion](https://github.com/microsoft/pyright/discussions/10365) uncovered an apparent bug. If the class `mpz` is renamed `i` (or any name beginning with a character prior to `i`), the overlapping overload error disappears.
I suspect this is partly explained by the sorting algorithm used internally by pyright for unions. Since the type is being unioned with `int`, a name that comes prior to `int` will result in `i | int` versus `int | mpz`. The ordering of a union should not matter when it comes to assignability, so there's some other bug involved here — probably in the logic for determining whether one union is assignable to another union when using special "overlapping overload" rules, which differ somewhat from normal assignability rules.
Contributor guide
Research direction
Start with the linked discussion and reproduce the overload error while renaming `mpz` to `i`. Trace union ordering and the overlapping-overload assignability logic described in the issue. Done means the error is consistent regardless of the type name or union order, with coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100