julia
julia copied to clipboard
Error message improvement for BoundsError: Print the exact problem indexes
Resolves #40747
Before:
[1,2,3][[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,]]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1 … 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]
After:
[1,2,3][[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,]]
ERROR: BoundsError: attempt to access 3-element Vector{Int64} at index [5] in [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1 … 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]
And a more complex example:
[1 2 3; 4 5 6][2:10, collect(1:10), 4]
ERROR: BoundsError: attempt to access 2×3 Matrix{Int64} at index [3:10, [4, 5, 6, 7, 8, 9, 10], 4] in [2:10, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 4]