fix(checker): adjust error message location
when constraint doesn't evaluate to a boolean, report error on the constraint expression instead of the whole type
This commit is contained in:
@@ -408,7 +408,7 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
|||||||
self._predicate_params = {}
|
self._predicate_params = {}
|
||||||
if not self.types.is_subtype(constraint_type, self._bool):
|
if not self.types.is_subtype(constraint_type, self._bool):
|
||||||
self.reporter.error(
|
self.reporter.error(
|
||||||
type.location,
|
type.constraint.location,
|
||||||
f"Constraint must evaluate to a boolean, got {constraint_type}",
|
f"Constraint must evaluate to a boolean, got {constraint_type}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user