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
Any code after an UninhabitedType is marked as unreachable in binder. This leads to dangerous behaviour together with how type inference currently works "in all uncertain situations infer uninhabited" (see also #3283 for discussion). For example no error is reported in this code:
fromtypingimportTypeVarT=TypeVar('T')
deff() ->T:
...
classC:
f()
1+'this is not checked'deffun() ->None:
f()
1+'can do everything here'ifTrue:
f()
1+'whatever'
There are other function signatures (all involve type variables) that lead to this behaviour: type checking stops after a call to such function.
The text was updated successfully, but these errors were encountered:
I think that in a dynamic settings ()->T should not be considered as returning Uninhabited. Similarly to how T->T is not necessarily the identity function.
Fixes#3994.
Currently code after inferred UninhabitedType is skipped. For example, no
errors are shown for the commented lines in this code:
```
T = TypeVar('T')
def f(x: List[T]) -> T:
...
class C:
x = f([])
def m(self) -> str:
return 42 # No error!
if bool():
f([])
1 + '' # No error!
```
There are other scenarios in tests. With this PR errors are shown as expected, since UninhabitedTypes resulting from ambiguous inference don't influence binder.
Any code after an
UninhabitedType
is marked as unreachable in binder. This leads to dangerous behaviour together with how type inference currently works "in all uncertain situations infer uninhabited" (see also #3283 for discussion). For example no error is reported in this code:There are other function signatures (all involve type variables) that lead to this behaviour: type checking stops after a call to such function.
The text was updated successfully, but these errors were encountered: