Crash in mypyc with recursive tuple TypeAlias
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
Related to Issue #13795, using certain types of tuple in a recursive TypeAlias causes mypyc to crash, even though mypy reports no errors.
To Reproduce
from typing import TypeAlias
RuleItem: TypeAlias = tuple["RuleItem"] | str
def fun(value: RuleItem) -> None:
pass
Also broken, with or without TypeAlias:
- RuleItem: TypeAlias = Union[tuple["RuleItem"], str]
- RuleItem: TypeAlias = Union[tuple["RuleItem", int], str]
- RuleItem: TypeAlias = Union[tuple["RuleItem", "RuleItem"], str]
- RuleItem: TypeAlias = Union[Tuple["RuleItem"], str]
- RuleItem: TypeAlias = Tuple["RuleItem"]
(After importing Union and Tuple from typing, of course.)
But these work:
- RuleItem: TypeAlias = Union[tuple[int], str]
- RuleItem: TypeAlias = Union[tuple["RuleItem", ...], str]
- RuleItem: TypeAlias = Union[list["RuleItem"], str]
- RuleItem: TypeAlias = Union[set["RuleItem"], str]
(That second option turns out to be what I really wanted anyway.)
Actual Behavior
The mypy command reports no errors.
Running the mypyc command on an affected file emits no output (even with a --show-traceback option) and exits with status code 245.
Running the mypyc.build.mypycify Python function on an affected file emits no output, and crashes Python with status code 139.
Your Environment
- Mypy version used: mypy 1.2.0 (compiled: yes)
- Mypy command-line flags:
--strict(optional) - Mypyc command-line flags:
--show-traceback(optional) - Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.10.6
- OS version used: Ubuntu 22.04.1 LTS
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte rekursive RuleItem-Beispiel mit mypy und mypyc auszuführen, und untersuche anschließend mypyc.build.mypycify sowie den von ihm aufgerufenen Compilerpfad. Bestätige die Fehlerbehebung, indem du sicherstellst, dass betroffene Aliase ohne Status 245 oder 139 kompiliert werden, während die aufgeführten funktionierenden Aliase weiterhin gültig bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100