Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def transform_class_def(builder: IRBuilder, cdef: ClassDef) -> None:

This is the main entry point to this module.
"""
if cdef.info not in builder.mapper.type_to_ir:
builder.error("Nested class definitions not supported", cdef.line)
return

ir = builder.mapper.type_to_ir[cdef.info]

# We do this check here because the base field of parent
Expand Down
12 changes: 12 additions & 0 deletions mypyc/test-data/irbuild-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -1300,3 +1300,15 @@ class T:

class E(T):
y: str # E: Type of "y" is incompatible with definition in trait "T"


[case testNestedClasses]
def outer():
class Inner: # E: Nested class definitions not supported
pass

return Inner

if True:
class OtherInner: # E: Nested class definitions not supported
pass
Loading