diff --git a/src/array_partition.jl b/src/array_partition.jl index 0bfdd68b..23ab35b9 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -219,6 +219,7 @@ Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Int) return A.x[j][length(A.x[j]) + i] end end + throw(BoundsError(A, i)) end """ diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 9f7aeb59..15c31655 100644 --- a/test/partitions_test.jl +++ b/test/partitions_test.jl @@ -1,6 +1,7 @@ using RecursiveArrayTools, Test, Statistics, ArrayInterface A = (rand(5), rand(5)) p = ArrayPartition(A) +@inferred p[1] @test (p.x[1][1], p.x[2][1]) == (p[1], p[6]) p = ArrayPartition(A, Val{true})