From aae481776f93afe5dab9d88365c8e2fe99016a48 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 8 Jul 2026 09:32:13 +0200 Subject: [PATCH] fix(checker): check ConstraintType's constraint type --- midas/checker/midas.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/midas/checker/midas.py b/midas/checker/midas.py index 5213785..e8cf791 100644 --- a/midas/checker/midas.py +++ b/midas/checker/midas.py @@ -407,8 +407,18 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type return UnknownType() def visit_constraint_type(self, type: m.ConstraintType) -> Type: + base_type: Type = type.type.accept(self) + self._predicate_params["_"] = base_type + constraint_type: Type = self.type_of(type.constraint) + self._predicate_params = {} + if not self.types.is_subtype(constraint_type, self._bool): + self.reporter.error( + type.location, + f"Constraint must evaluate to a boolean, got {constraint_type}", + ) + return ConstraintType( - type=type.type.accept(self), + type=base_type, constraint=type.constraint, )