fix: make free error message more clear
This commit is contained in:
parent
e87e61b152
commit
b5e72660b7
@ -125,7 +125,7 @@ object typeChecker {
|
|||||||
Constraint.IsEither(
|
Constraint.IsEither(
|
||||||
KnownType.Array(?),
|
KnownType.Array(?),
|
||||||
KnownType.Pair(?, ?),
|
KnownType.Pair(?, ?),
|
||||||
"free must be an array or pair"
|
"free must be applied to an array or pair"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case Return(expr) =>
|
case Return(expr) =>
|
||||||
@ -163,6 +163,7 @@ object typeChecker {
|
|||||||
checkValue(elem, Constraint.Is(KnownType.Int, "array index must be an int"))
|
checkValue(elem, Constraint.Is(KnownType.Int, "array index must be an int"))
|
||||||
acc match {
|
acc match {
|
||||||
case KnownType.Array(innerTy) => Some(innerTy)
|
case KnownType.Array(innerTy) => Some(innerTy)
|
||||||
|
case ? => Some(?)
|
||||||
case nonArrayTy =>
|
case nonArrayTy =>
|
||||||
ctx.error(
|
ctx.error(
|
||||||
Error.TypeMismatch(elem.pos, KnownType.Array(?), acc, "cannot index into a non-array")
|
Error.TypeMismatch(elem.pos, KnownType.Array(?), acc, "cannot index into a non-array")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user