Refactor child types

Didn't change the actual syntax, but changed the rules around to be less
confusing.
This commit is contained in:
James Westman 2023-04-29 21:16:14 -05:00
parent 9dcd06de51
commit 71f52d350a
11 changed files with 74 additions and 55 deletions

View file

@ -109,9 +109,9 @@ class AstNode:
else:
return self.parent.root
def parent_by_type(self, type):
def parent_by_type(self, type: T.Type[TType]) -> TType:
if self.parent is None:
return None
raise CompilerBugError()
elif isinstance(self.parent, type):
return self.parent
else: