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

Crash in mypyc with recursive tuple TypeAlias #15092

Open
eswald opened this issue Apr 20, 2023 · 0 comments
Open

Crash in mypyc with recursive tuple TypeAlias #15092

eswald opened this issue Apr 20, 2023 · 0 comments
Labels
bug mypy got something wrong topic-mypyc mypyc bugs

Comments

@eswald
Copy link

eswald commented Apr 20, 2023

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
@eswald eswald added the bug mypy got something wrong label Apr 20, 2023
@ichard26 ichard26 added the topic-mypyc mypyc bugs label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-mypyc mypyc bugs
Projects
None yet
Development

No branches or pull requests

2 participants