Skip to content

Fix testLiteralMeets failure - #15659

Merged
hauntsaninja merged 1 commit into
python:masterfrom
ikonst:07-13-Fix_testLiteralMeets_failure
Jul 13, 2023
Merged

Fix testLiteralMeets failure#15659
hauntsaninja merged 1 commit into
python:masterfrom
ikonst:07-13-Fix_testLiteralMeets_failure

Conversation

@ikonst

@ikonst ikonst commented Jul 13, 2023

Copy link
Copy Markdown
Contributor

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

Fixes #15657.

@ikonst

ikonst commented Jul 13, 2023

Copy link
Copy Markdown
Contributor Author

👁️ @sobolevn

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

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 :)


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

Copy link
Copy Markdown
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.

@ikonst ikonst Jul 13, 2023

Copy link
Copy Markdown
Contributor Author

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
@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