fix: check both sides are unknown for assign error message
This commit is contained in:
parent
3d2725be8d
commit
8a7b37e05f
@ -95,28 +95,27 @@ object typeChecker {
|
||||
)
|
||||
case Assign(lhs, rhs) =>
|
||||
val lhsTy = checkValue(lhs, Constraint.Unconstrained)
|
||||
checkValue(rhs, Constraint.Is(lhsTy, s"assignment must have type $lhsTy")) match {
|
||||
case ? =>
|
||||
(lhsTy, checkValue(rhs, Constraint.Is(lhsTy, s"assignment must have type $lhsTy"))) match {
|
||||
case (?, ?) =>
|
||||
ctx.error(
|
||||
Error.SemanticError(lhs.pos, "assignment with both sides of unknown type is illegal")
|
||||
)
|
||||
case _ => ()
|
||||
}
|
||||
case Read(lhs) =>
|
||||
val lhsTy = checkValue(lhs, Constraint.Unconstrained)
|
||||
lhsTy match {
|
||||
case Read(dest) =>
|
||||
checkValue(dest, Constraint.Unconstrained) match {
|
||||
case ? =>
|
||||
ctx.error(
|
||||
Error.SemanticError(lhs.pos, "cannot read into a destination with an unknown type")
|
||||
Error.SemanticError(dest.pos, "cannot read into a destination with an unknown type")
|
||||
)
|
||||
case _ =>
|
||||
lhsTy.satisfies(
|
||||
case destTy =>
|
||||
destTy.satisfies(
|
||||
Constraint.IsEither(
|
||||
KnownType.Int,
|
||||
KnownType.Char,
|
||||
"read must be applied to an int or char"
|
||||
),
|
||||
lhs.pos
|
||||
dest.pos
|
||||
)
|
||||
}
|
||||
case Free(lhs) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user