refactor: fail on ? snd or fst type-check result

This commit is contained in:
Gleb Koval 2025-02-07 12:26:04 +00:00
parent f143f685c4
commit 4e10fb3fda
Signed by: cyclane
GPG Key ID: 15E168A8B332382C

View File

@ -203,7 +203,6 @@ object typeChecker {
) match { ) match {
case what @ KnownType.Pair(left, _) => case what @ KnownType.Pair(left, _) =>
left.satisfies(constraint, elem.pos) left.satisfies(constraint, elem.pos)
case ? => ?.satisfies(constraint, elem.pos)
case _ => ctx.error(Error.InternalError(elem.pos, "fst must be applied to a pair")) case _ => ctx.error(Error.InternalError(elem.pos, "fst must be applied to a pair"))
} // satisfies constraint } // satisfies constraint
case Snd(elem) => case Snd(elem) =>
@ -212,7 +211,6 @@ object typeChecker {
Constraint.Is(KnownType.Pair(?, ?), "snd must be applied to a pair") Constraint.Is(KnownType.Pair(?, ?), "snd must be applied to a pair")
) match { ) match {
case KnownType.Pair(_, right) => right.satisfies(constraint, elem.pos) case KnownType.Pair(_, right) => right.satisfies(constraint, elem.pos)
case ? => ?.satisfies(constraint, elem.pos)
case _ => ctx.error(Error.InternalError(elem.pos, "snd must be applied to a pair")) case _ => ctx.error(Error.InternalError(elem.pos, "snd must be applied to a pair"))
} }