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 crash in match statement if class name is undefined #12417

Merged
merged 2 commits into from Mar 22, 2022
Merged

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Mar 21, 2022

Fixes #12416.


match m:
case xyz(y=z): # E: Name "xyz" is not defined
reveal_type(y) # E: Cannot determine type of "y" \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
reveal_type(y) # E: Cannot determine type of "y" \
reveal_type(z) # E: Cannot determine type of "z" \

I think it picks it up y from the previous match

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, updated.

match m:
case xyz(y): # E: Name "xyz" is not defined
reveal_type(m) # N: Revealed type is "Any"
reveal_type(y) # E: Cannot determine type of "y" \
Copy link
Member

Choose a reason for hiding this comment

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

"Cannot determine type" is a bit unfortunate; I'd rather it's just Any. Probably fine this way though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, Any would be better, but I think that this would require a much bigger change.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JukkaL JukkaL merged commit b814ae1 into master Mar 22, 2022
@JukkaL JukkaL deleted the fix-match-crash branch March 22, 2022 09:56
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.

Crash if class name is misspelled in match statement
3 participants