fix: make int binary operators and char binary operators errors consistent
This commit is contained in:
parent
8a7b37e05f
commit
4d25d7a730
@ -246,18 +246,17 @@ object typeChecker {
|
|||||||
)
|
)
|
||||||
KnownType.Bool.satisfies(constraint, op.pos)
|
KnownType.Bool.satisfies(constraint, op.pos)
|
||||||
case op: (Less | LessEq | Greater | GreaterEq) =>
|
case op: (Less | LessEq | Greater | GreaterEq) =>
|
||||||
val xTy = checkValue(
|
val xConstraint = Constraint.IsEither(
|
||||||
op.x,
|
KnownType.Int,
|
||||||
Constraint.IsEither(
|
KnownType.Char,
|
||||||
KnownType.Int,
|
s"${op.name} operator must be applied to an int or char"
|
||||||
KnownType.Char,
|
|
||||||
s"${op.name} operator must be applied to an int or char"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
checkValue(
|
|
||||||
op.y,
|
|
||||||
Constraint.Is(xTy, s"${op.name} operator must be applied to values of the same type")
|
|
||||||
)
|
)
|
||||||
|
val yConstraint = checkValue(op.x, xConstraint) match {
|
||||||
|
case ? => xConstraint
|
||||||
|
case xTy =>
|
||||||
|
Constraint.Is(xTy, s"${op.name} operator must be applied to values of the same type")
|
||||||
|
}
|
||||||
|
checkValue(op.y, yConstraint)
|
||||||
KnownType.Bool.satisfies(constraint, op.pos)
|
KnownType.Bool.satisfies(constraint, op.pos)
|
||||||
case op: (And | Or) =>
|
case op: (And | Or) =>
|
||||||
val operand = Constraint.Is(KnownType.Bool, s"${op.name} operator must be applied to a bool")
|
val operand = Constraint.Is(KnownType.Bool, s"${op.name} operator must be applied to a bool")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user