fix: foldLeft when type checking, rather than foldRight which is unintuitive
This commit is contained in:
parent
68e4762b37
commit
319fa606d9
@ -159,7 +159,7 @@ object typeChecker {
|
||||
ctx.typeOf(id).satisfies(constraint, id.pos)
|
||||
case ArrayElem(id, indices) =>
|
||||
val arrayTy = ctx.typeOf(id)
|
||||
val elemTy = indices.toList.foldRight(arrayTy) { (elem, acc) =>
|
||||
val elemTy = indices.foldLeft(arrayTy) { (acc, elem) =>
|
||||
checkValue(elem, Constraint.Is(KnownType.Int, "array index must be an int"))
|
||||
acc match {
|
||||
case KnownType.Array(innerTy) => innerTy
|
||||
@ -173,10 +173,10 @@ object typeChecker {
|
||||
case Parens(expr) => checkValue(expr, constraint)
|
||||
case l @ ArrayLiter(elems) =>
|
||||
KnownType
|
||||
.Array(elems.foldRight[SemType](?) { case (elem, acc) =>
|
||||
.Array(elems.foldLeft[SemType](?) { case (acc, elem) =>
|
||||
checkValue(
|
||||
elem,
|
||||
Constraint.IsSymmetricCompatible(acc, "array elements must have the same type")
|
||||
Constraint.IsSymmetricCompatible(acc, s"array elements must have the same type")
|
||||
)
|
||||
})
|
||||
.satisfies(constraint, l.pos)
|
||||
|
Loading…
x
Reference in New Issue
Block a user