Skip to content

Commit

Permalink
Unify processing of array types in TypeDetector
Browse files Browse the repository at this point in the history
Both ArrayTypeInStream and CalcArrayType the only existing successors
of the sealed class TypeDetector so we can do that simplification
  • Loading branch information
Mingun committed Apr 10, 2023
1 parent 702633b commit b313a13
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,9 @@ class TypeDetector(provider: TypeProvider) {
}
case Ast.expr.Subscript(container: Ast.expr, idx: Ast.expr) =>
(detectType(container) match {
case ArrayTypeInStream(elType: DataType) =>
case arr: ArrayType =>
detectType(idx) match {
case _: IntType => elType
case idxType => throw new TypeMismatchError(s"unable to index an array using $idxType")
}
case CalcArrayType(elType: DataType) =>
detectType(idx) match {
case _: IntType => elType
case _: IntType => arr.elType
case idxType => throw new TypeMismatchError(s"unable to index an array using $idxType")
}
case _: BytesType => Int1Type(false)
Expand Down

0 comments on commit b313a13

Please sign in to comment.