Skip to content

Avoid calling join during semantic analysis #3316

Closed
@JukkaL

Description

@JukkaL

We shouldn't call join during semantic analysis, since the MROs of classes may be incomplete and other things may be inconsistent, potentially resulting in crashes.

This comment has additional context: https://github.com/python/mypy/pull/3305/files#r114751204

Quote:

We can't use type joins safely during semantic analysis, since MROs may be incomplete :-(

One potential way to fix this would be to postpone all joins to a new, fourth semantic analysis pass. That sounds risky though, so for the 0.510 release we could just use Any here as the fallback as a temporary workaround.

This has happened so many times that I've been considering asserting during joins and other type operations that need MROs that they aren't called during semantic analysis, at least when running tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions