Skip to content

Fix crash on unnormalized tuples in deferred type alias - #22096

Open
ilevkivskyi wants to merge 1 commit into
python:masterfrom
ilevkivskyi:fix-tvt-ta-crash
Open

ilevkivskyi wants to merge 1 commit into
python:masterfrom
ilevkivskyi:fix-tvt-ta-crash

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

Fixes #21933

It is crucial that TypeAlias node is created once, and then modified in-place in case of deferrals. This is how recursive types were implemented, and a lot of code relies on this. However, rvalue.analyzed (and s.alias_node for new-style aliases) were getting a new alias node each time. And these are the ways MixedTraverser finds type aliases to perform type normalization. Therefore, we could get non-normalized tuples (and other problematic types) in case of a deferred type alias.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi ilevkivskyi changed the title Fix unnormalized tuples in deferred type alias Fix crash on unnormalized tuples in deferred type alias Oct 4, 2026
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 on unpacked tuple in tuple type definition

1 participant