Skip to content

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

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
ilevkivskyi:fix-tvt-ta-crash
Oct 5, 2026
Merged

ilevkivskyi merged 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
@ilevkivskyi
ilevkivskyi merged commit 09f2ca6 into python:master Oct 5, 2026
25 checks passed
@ilevkivskyi
ilevkivskyi deleted the fix-tvt-ta-crash branch October 5, 2026 12:16
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

2 participants