From c333735580a7a8c900ad2b9a3743af3097e3243f Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Mon, 29 Jun 2026 11:06:35 +0200 Subject: [PATCH] fix(checker): allow subtypes and unknown as if test --- midas/checker/python.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/midas/checker/python.py b/midas/checker/python.py index 29855b1..37562c4 100644 --- a/midas/checker/python.py +++ b/midas/checker/python.py @@ -439,8 +439,10 @@ class PythonTyper( # print(m) # <- m is still defined test_type: Type = self.type_of(stmt.test) - # TODO Allow subtypes or any type - if test_type != self.types.get_type("bool"): + if ( + not self.types.is_subtype(test_type, self.types.get_type("bool")) + and test_type != UnknownType() + ): self.reporter.error( stmt.test.location, f"If test must be a boolean, got {test_type}" ) @@ -638,7 +640,10 @@ class PythonTyper( test_type: Type = self.type_of(expr.test) # TODO Allow subtypes or any type - if test_type != self.types.get_type("bool"): + if ( + not self.is_subtype(test_type, self.types.get_type("bool")) + and test_type != UnknownType() + ): self.reporter.error( expr.test.location, f"If test must be a boolean, got {test_type}" )