# ArgumentError: unable to check bounds for indices of type Index

**URL:** <https://discourse.julialang.org/t/argumenterror-unable-to-check-bounds-for-indices-of-type-index/89759>\
**Category:** General Usage\
**Created:** [November 4, 2022, 7:43am UTC](https://discourse.julialang.org/t/argumenterror-unable-to-check-bounds-for-indices-of-type-index/89759 "2022-11-04T07:43:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Post date:** [November 4, 2022, 7:43am UTC](https://discourse.julialang.org/t/argumenterror-unable-to-check-bounds-for-indices-of-type-index/89759/1 "2022-11-04T07:43:18Z")

</div>

This is going to be an easy one, because it’s probably about pointing me to the right place in the docs: My MWE

```julia
struct Index
    i::Int64
end
Base.getindex(A::AbstractArray,i::Index) = A[i.i]

index = [Index(1),Index(3)]
A = [1.,2.,3.,4.]

@show A[index[2]]
@show A[index]

```

results in

```julia
A[index[2]] = 3.0
ERROR: ArgumentError: unable to check bounds for indices of type Index

```

So accessing array `A` with an `Index` works, but not with a `Vector` of `Index`. I do not understand why there should be a bound checking issue. Checking what? Is it about the bounds of `A` (why did scalar indexing work?) or of `index` (`index` is a plain old `Vector`, surely, the first index is `1`)?

Confusion achieved! 😀

---

<div class="post-metadata">

**Author:** ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Post date:** [November 4, 2022, 8:14am UTC](https://discourse.julialang.org/t/argumenterror-unable-to-check-bounds-for-indices-of-type-index/89759/2 "2022-11-04T08:14:18Z")

</div>

By adding

```julia
Base.getindex(A::AbstractArray,is::AbstractArray{Index}) = [A[i.i] for i ∈is]

```

i get things to work as intended. But I have an uneasy feeling: if this is a robust and fast solution, why isn’t such a method (not specialised to `Index`) part of Base`?
