feat(checker): catch errors when evaluating constraint

This commit is contained in:
2026-07-01 14:06:01 +02:00
parent 8fc5ab623e
commit a017a8cf1f

View File

@@ -989,10 +989,19 @@ class PythonTyper(
evaluator = Evaluator(self.types)
evaluator.set_value("_", lit_value)
res = evaluator.evaluate(constraint)
printer = MidasPrinter()
constraint_str: str = printer.print(constraint)
res: Any
try:
res = evaluator.evaluate(constraint)
except Exception as e:
self.reporter.error(
expr.location,
f"An error occurred while checking constraint '{constraint_str}' on the value {lit_value!r}: {e}",
)
return False
if not res:
printer = MidasPrinter()
constraint_str: str = printer.print(constraint)
self.reporter.error(
expr.location,
f"Value {lit_value!r} does not fit constraint '{constraint_str}'",