You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defbool_instance() ->bool:
returnTruex: Literal[42, "hello"] =42ifbool_instance() else"hello"reveal_type(x) # revealed: Literal[42] | Literal["hello"]_=1234ifisinstance(x, str) else1234# The `isinstance` test incorrectly narrows the type of `x`.# As a result, `x` is revealed as Literal["hello"], but it should remain Literal[42, "hello"].reveal_type(x) # revealed: Literal["hello"]
This issue is not limited to isinstance. Other narrowing expressions or patterns also cause the same issue.
The text was updated successfully, but these errors were encountered:
If this isn't resolved first, #14550 could break some tests.
I'll take a look into it first.
cake-monotone
changed the title
[red-knot] Incorrect Narrowing Constraint Applied After IfExp
[red-knot] Incorrect Narrowing Constraint Applied After ExprIf
Nov 25, 2024
This issue is not limited to
isinstance
. Other narrowing expressions or patterns also cause the same issue.The text was updated successfully, but these errors were encountered: