segfault on recursive generic function class
Open
Nobody has claimed this yet.
crash
topic-recursive-types
topic-type-variables
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report
Seg fault
Traceback
$ mypy . --show-traceback
Segmentation fault (core dumped)
To Reproduce
(Write what you did to reproduce the crash. Full source code is
appreciated. We also very much appreciate it if you try to narrow the
source down to a small stand-alone example.)
from __future__ import annotations
from typing import Callable
class Wrapper:
def __call__[**P, T](
self,
func: Callable[P, T] | None = None,
) -> Callable[P, T] | Wrapper:
if func is not None:
return func
return Wrapper()
Your Environment
- Mypy version used: 1.13.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.13.0
- Operating system and version: wsl 2.3.26.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
First reproduce the crash with the provided Wrapper example using mypy . --show-traceback under the reported environment. Trace the recursive generic-function handling in mypy and add a regression test for the example; done means mypy reports the source without a segmentation fault.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100