Skip to content

Use of Annotated[T, ...] in a recursive type results in a hang or crash #17220

Description

@LeeeeT

The following code causes mypy to never terminate.

from typing import Annotated, TypeVar


T = TypeVar("T")

R = Annotated[T, ...]

A = R["A"]

It can be turned into a sample that causes a segmentation fault.

from typing import Annotated, TypeVar


T = TypeVar("T")

R = Annotated[T, ...]

A = list[R["A"]]


def f() -> A:
    return []
  • Mypy version used: 1.10.0
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.12
  • Operating system and version: Linux, Windows (on Windows it immediately exits with code 1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions