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

Pyre cannot narrow literal types #911

Open
vthemelis opened this issue Aug 23, 2024 · 0 comments
Open

Pyre cannot narrow literal types #911

vthemelis opened this issue Aug 23, 2024 · 0 comments
Assignees

Comments

@vthemelis
Copy link
Contributor

vthemelis commented Aug 23, 2024

Pyre Bug

Bug description

Pyre cannot reason about narrowing of literal types:

from typing import Literal, assert_never

def foo(x: Literal["a", "b"]) -> str:
    if x == "a":
        return "a"
    if x == "b":
        return "b"
    else:
        assert_never(x)

This should obviously type check (and it does for pyright)

See Pyre playground

@yangdanny97 yangdanny97 self-assigned this Aug 23, 2024
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