Skip to content

Code is not cheked after some function calls: binder/inference bug #3994

Closed

Description

@ilevkivskyi

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:

from typing import TypeVar
T = TypeVar('T')

def f() -> T:
    ...

class C:
    f()
    1 + 'this is not checked'

def fun() -> None:
    f()
    1 + 'can do everything here'

if True:
    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.

Activity

  1. elazarg commented on Sep 24, 2017

    @elazarg
    Contributor

    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.

  2. added a commit that references this issue on Oct 20, 2017
    1673e27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions