Closed
Description
Bug report
Bug description:
The code for the following AST is:
type foo['x'] = Callable
compiling the AST for the given code results in a segmentation fault
from ast import *
m = Module(
body=[
TypeAlias(
name=Subscript(
value=Name(id="foo", ctx=Load()),
slice=Constant(value="x"),
ctx=Store(),
),
type_params=[],
value=Name(id="Callable", ctx=Load()),
)
],
type_ignores=[],
)
compile(fix_missing_locations(m), "<file>", "exec")
output (Python 3.12.0rc2+):
fish: Job 1, 'venv3.12/bin/python bug.py' terminated by signal SIGSEGV (Adressbereichsfehler)
Compiling the code gives the correct syntax error.
compile("type foo['x'] = Callable","<file>","exec")
output (Python 3.12.0rc2+):
Traceback (most recent call last):
File "/home/frank/projects/executing/bug.py", line 1, in <module>
compile("type foo['x'] = Callable","<file>","exec")
File "<file>", line 1
type foo['x'] = Callable
^^^
SyntaxError: invalid syntax
CPython versions tested on:
3.12
Operating systems tested on:
No response