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

[red-knot] Incorrect control flow modelling in if-elif chains #15033

Closed
sharkdp opened this issue Dec 17, 2024 · 5 comments · Fixed by #15274
Closed

[red-knot] Incorrect control flow modelling in if-elif chains #15033

sharkdp opened this issue Dec 17, 2024 · 5 comments · Fixed by #15274
Labels
bug Something isn't working red-knot Multi-file analysis & type inference

Comments

@sharkdp
Copy link
Contributor

sharkdp commented Dec 17, 2024

We currently infer a type of Literal[1, 2, 4] in the following example, but 1 is not a possible value of x. And 3 is a possible value for x.

def check(x: int) -> bool: ...

if check(x := 1):
    x = 2
elif check(x := 3):
    x = 4

reveal_type(x)  # revealed: Literal[1, 2, 4]; should be Literal[2, 3, 4]
@sharkdp sharkdp added the red-knot Multi-file analysis & type inference label Dec 17, 2024
@AlexWaygood

This comment has been minimized.

@sharkdp

This comment has been minimized.

@AlexWaygood

This comment has been minimized.

@sharkdp

This comment has been minimized.

@AlexWaygood

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants