Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeVar fails to compile when using recursive type annotation #3009

Open
DragonMoffon opened this issue Jul 16, 2024 · 1 comment
Open

TypeVar fails to compile when using recursive type annotation #3009

DragonMoffon opened this issue Jul 16, 2024 · 1 comment
Assignees
Milestone

Comments

@DragonMoffon
Copy link
Contributor

2.4rc10
Commercial: None
Python: 3.12.3 (tags/v3.12.3:f6650f9, Apr 9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)]
Flavor: CPython Official
Executable: C:\Users\Playtech\Desktop\Code\Python\Nuitka.libs\Scripts\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 11

code compiled with forked Nuitka, and the issue was observed in the latest version (fresh install)

code required to get crash:

from typing import Iterable
type Flatable[T] = T | Iterable[Flatable[T]]

with command python -m nuitka <file>

warning in console log:

Nuitka-Optimization:WARNING: Problem at 'temp\recursive_type.py:2' with TypeAlias(name=Name(id='Flatable', ctx=Store()), type_params=[TypeVar(name='T')], value=BinOp(left=Name(id='T', ctx=Load()), op=BitOr(),
Nuitka-Optimization:WARNING: right=Subscript(value=Name(id='Iterable', ctx=Load()), slice=Subscript(value=Name(id='Flatable', ctx=Load()), slice=Name(id='T', ctx=Load()), ctx=Load()), ctx=Load()))).
@kayhayen kayhayen added the bug label Jul 20, 2024
@kayhayen kayhayen self-assigned this Jul 20, 2024
@kayhayen kayhayen added this to the 2.5 milestone Jul 20, 2024
@kayhayen
Copy link
Member

So, this is similar how it's needed to be done for classes (generics), a closure taking function needs to preserve a variable value given as an argument into a closure and then work on that in a pseudo function. I will try and have this for 2.5 release in a first development sprint.

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

No branches or pull requests

2 participants