From ad40db98d084d7c41f30a2e0e79f664f47a5d89e Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Thu, 9 Jul 2026 17:46:52 +0200 Subject: [PATCH] fix(checker): always type check unary operand --- midas/checker/midas.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/midas/checker/midas.py b/midas/checker/midas.py index 3efa5d4..cd691ea 100644 --- a/midas/checker/midas.py +++ b/midas/checker/midas.py @@ -292,6 +292,9 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type return result.result def visit_unary_expr(self, expr: m.UnaryExpr) -> Type: + # First evaluate operand to surface all errors + operand: Type = self.type_of(expr.right) + # Special case because there is no __not__ dunder method match expr.operator: case Token(type=TokenType.BANG): @@ -305,7 +308,6 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type ) return UnknownType() - operand: Type = self.type_of(expr.right) operation: Optional[Type] = self.types.lookup_member(operand, method) if operation is None: self.reporter.error(