Skip to content

Segfault crash on specific recursive type situation #20107

Description

@phiddypus

Bug Report

Mypy segfaults when checking the following code.

To Reproduce

(Gist)

from typing import Self, Union

type OneClass = list[OneClass|int]

class TwoClass (list[Union['TwoClass',int]]):
    @classmethod
    def meth (cls, obj:Self|OneClass) -> Self|None:
        if isinstance(obj, cls): return obj

Actual Behavior

In terminal:

Segmentation fault         (core dumped) mypy test.py

In gist:

Failed (exit code: -11)

Your Environment

  • Mypy version used: mypy 1.18.2 (compiled: yes)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: Python 3.13.7

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