diff --git a/src/main/wacc/typeChecker.scala b/src/main/wacc/typeChecker.scala index 38b34e3..f0f523b 100644 --- a/src/main/wacc/typeChecker.scala +++ b/src/main/wacc/typeChecker.scala @@ -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)