Skip to content

Conversation

mtshiba
Copy link
Contributor

@mtshiba mtshiba commented Sep 23, 2025

Summary

I found this bug while working on #20528.
The minimum reproducible code is:

from __future__ import annotations

from typing import NamedTuple
from ty_extensions import is_disjoint_from, static_assert

class Path(NamedTuple):
    prev: Path | None
    key: str

static_assert(not is_disjoint_from(Path, Path))

A stack overflow occurs when a nominal instance type inherits from NamedTuple and is defined recursively.
This PR fixes this bug.

Test Plan

mdtest updated

Copy link
Contributor

github-actions bot commented Sep 23, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@mtshiba mtshiba force-pushed the recursive-nominal-instance-is-disjoint-from branch from f0075c7 to a04a7c2 Compare September 23, 2025 16:45
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@mtshiba mtshiba marked this pull request as ready for review September 23, 2025 16:59
Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you!

@sharkdp sharkdp merged commit 722f1a7 into astral-sh:main Sep 23, 2025
39 checks passed
@mtshiba mtshiba deleted the recursive-nominal-instance-is-disjoint-from branch September 24, 2025 01:39
@ntBre ntBre added the ty Multi-file analysis & type inference label Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants