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

Fix testLiteralMeets failure #15659

Merged

Conversation

ikonst
Copy link
Contributor

@ikonst ikonst commented Jul 13, 2023

Since #15386, any uninhabited type in module scope causes the rest of the block to go unchecked.

Fixes #15657.

@ikonst
Copy link
Contributor Author

ikonst commented Jul 13, 2023

👁️ @sobolevn

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I want someone else to review this as well :)

@@ -1797,7 +1797,8 @@ def f5(x: Literal[1], y: Union[Literal[1], Literal[2]]) -> None: pass
def f6(x: Optional[Literal[1]], y: Optional[Literal[2]]) -> None: pass

reveal_type(unify(f1)) # N: Revealed type is "Literal[1]"
reveal_type(unify(f2)) # N: Revealed type is "<nothing>"
if object():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a regression to me, because this is not "really <nothing>, execution is stopped", it is just "we cannot do a better job with two literal values".

In the long run we need to figure out how to tell these two cases apart.

Copy link
Contributor Author

@ikonst ikonst Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always the case for function scope. I only made module scope work the same way.

I agree that entire behavior leaves a lot to be desired, and I'll try to work on that next.

(Fwiw, it's also broken that "cannot call function of unknown type" is treated differently than "expression has uninhibited type".)

@hauntsaninja hauntsaninja merged commit 3983381 into python:master Jul 13, 2023
12 checks passed
@ikonst ikonst deleted the 07-13-Fix_testLiteralMeets_failure branch July 13, 2023 20:08
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

Successfully merging this pull request may close these issues.

main branch failure: [case testLiteralMeets] fails
3 participants