feat: reduce appearances of unknown-type, catch illegal function calls #19

Merged
gk1623 merged 6 commits from error-message-improvements into master 2025-02-07 18:14:37 +00:00
2 changed files with 11 additions and 2 deletions
Showing only changes of commit b5e72660b7 - Show all commits

View File

@@ -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")