refactor: comment non-trivial code in typeChecker.scala #20

Merged
gk1623 merged 2 commits from comment-type-checker into master 2025-02-07 18:45:51 +00:00
Showing only changes of commit 84932edb69 - Show all commits

View File

@@ -28,7 +28,7 @@ object typeChecker {
// Allows weakening in both directions, useful for array literals // Allows weakening in both directions, useful for array literals
case IsSymmetricCompatible(ty: SemType, msg: String) case IsSymmetricCompatible(ty: SemType, msg: String)
// Does not allow weakening // Does not allow weakening
case IsUnweakanable(ty: SemType, msg: String) case IsUnweakenable(ty: SemType, msg: String)
case IsEither(ty1: SemType, ty2: SemType, msg: String) case IsEither(ty1: SemType, ty2: SemType, msg: String)
case Never(msg: String) case Never(msg: String)
} }
@@ -57,8 +57,8 @@ object typeChecker {
KnownType.String KnownType.String
case (ty, Constraint.IsSymmetricCompatible(ty2, msg)) => case (ty, Constraint.IsSymmetricCompatible(ty2, msg)) =>
ty.satisfies(Constraint.Is(ty2, msg), pos) ty.satisfies(Constraint.Is(ty2, msg), pos)
// Change to IsUnweakanable to disallow recursive weakening // Change to IsUnweakenable to disallow recursive weakening
case (ty, Constraint.Is(ty2, msg)) => ty.satisfies(Constraint.IsUnweakanable(ty2, msg), pos) case (ty, Constraint.Is(ty2, msg)) => ty.satisfies(Constraint.IsUnweakenable(ty2, msg), pos)
case (ty, Constraint.Unconstrained) => ty case (ty, Constraint.Unconstrained) => ty
case (ty, Constraint.Never(msg)) => case (ty, Constraint.Never(msg)) =>
ctx.error(Error.SemanticError(pos, msg)) ctx.error(Error.SemanticError(pos, msg))
@@ -66,7 +66,7 @@ object typeChecker {
(ty moreSpecific ty1).orElse(ty moreSpecific ty2).getOrElse { (ty moreSpecific ty1).orElse(ty moreSpecific ty2).getOrElse {
ctx.error(Error.TypeMismatch(pos, ty1, ty, msg)) ctx.error(Error.TypeMismatch(pos, ty1, ty, msg))
} }
case (ty, Constraint.IsUnweakanable(ty2, msg)) => case (ty, Constraint.IsUnweakenable(ty2, msg)) =>
(ty moreSpecific ty2).getOrElse { (ty moreSpecific ty2).getOrElse {
ctx.error(Error.TypeMismatch(pos, ty2, ty, msg)) ctx.error(Error.TypeMismatch(pos, ty2, ty, msg))
} }