From 3416546eac980beaf66729c3052cfcea0e95ba38 Mon Sep 17 00:00:00 2001 From: James Westman Date: Thu, 5 May 2022 10:03:37 -0500 Subject: [PATCH] Expression: Fix some crashes --- blueprintcompiler/language/expression.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blueprintcompiler/language/expression.py b/blueprintcompiler/language/expression.py index b4bcde1..5a2c209 100644 --- a/blueprintcompiler/language/expression.py +++ b/blueprintcompiler/language/expression.py @@ -106,7 +106,8 @@ class ClosureExpr(AstNode): @property def gir_type(self): - return self.parent.parent.gir_type + if isinstance(self.parent.parent, CastExpr): + return self.parent.parent.gir_type @property def glib_type_name(self): @@ -125,8 +126,9 @@ class LookupOp(InfixExpr): @property def gir_type(self): if parent_type := self.lhs.gir_type: - if prop := parent_type.properties.get(self.tokens["property"]): - return prop.type + if isinstance(parent_type, gir.Class) or isinstance(parent_type, gir.Interface): + if prop := parent_type.properties.get(self.tokens["property"]): + return prop.type @property def glib_type_name(self):