Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable (not actually) code allows type errors #6276

Closed
andy-hanson opened this issue Jan 31, 2019 · 1 comment
Closed

Unreachable (not actually) code allows type errors #6276

andy-hanson opened this issue Jan 31, 2019 · 1 comment

Comments

@andy-hanson
Copy link

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request? Bug
def f() -> int:
    if False:
        return "".fake_method()

    res = None
    for x in (1, 2, 3):
        if res is not None:
            return ""
        res = x
    return 123


print(f() ** 2)  # Fails at runtime
  • What is the actual behavior/output?

No errors.

  • What is the behavior/output you expect?

At least, an error at return "" since this code is reachable (the second time through the loop).
An error in the genuinely unreachable code would be nice too.

  • What are the versions of mypy and Python you are using? mypy 0.670+dev.07440753dd80b6c5144031b4f614f3e7dabe7fcf (installed from master just now)

  • What are the mypy flags you are using? (For example --strict-optional) None

@ilevkivskyi
Copy link
Member

Duplicate of #5423

@ilevkivskyi ilevkivskyi marked this as a duplicate of #5423 Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants