Skip to content

Fix crash on ErasedType and covers_at_runtime - #11924

Merged
JukkaL merged 5 commits into
python:masterfrom
sobolevn:issue-11913
Jan 7, 2022
Merged

JukkaL merged 5 commits into
python:masterfrom
sobolevn:issue-11913

Conversation

@sobolevn

@sobolevn sobolevn commented Jan 6, 2022

Copy link
Copy Markdown
Member

Closes #11913
Refs #11273
CC @hauntsaninja

Comment thread mypy/subtypes.py Outdated
item = get_proper_type(item)
supertype = get_proper_type(supertype)
if (isinstance(item, (ErasedType, DeletedType))
or isinstance(supertype, (ErasedType, DeletedType))):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm I wonder if ErasedType instances can be nested inside unions, for example, and still cause a crash. Maybe erase_type should just propagate erased types unmodified? I don't think that DeletedType can be nested so it seems safe to handle here, though I'm not sure we need special casing for it. Did you find a use case where we encounter deleted types here, or is it here more as a defensive measure?

@sobolevn sobolevn Jan 6, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, good idea. I will try it!

Did you find a use case where we encounter deleted types here, or is it here more as a defensive measure?

More like a defensive programming. I will remove it, because it does not make much sense without ErasedType.

Comment thread test-data/unit/check-inference.test Outdated
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates!

@JukkaL
JukkaL merged commit a0f27b1 into python:master Jan 7, 2022
JukkaL pushed a commit that referenced this pull request Jan 7, 2022
Closes #11913
Refs #11273

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Closes python#11913
Refs python#11273

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
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.

INTERNAL ERROR RuntimeError in visit_erased_type with mypy 0.930

3 participants