pyright icon indicating copy to clipboard operation
pyright copied to clipboard

Overlapping overload error changes depending on type name

Open erictraut opened this issue 8 months ago • 0 comments

This discussion 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.

erictraut avatar Apr 24 '25 19:04 erictraut