Skip to content

Commit a1106b8

Browse files
authored
error message for indexing with BitArray (#38689)
* error message for indexing with BitArray * modify show_index instead * use BitMatrix in error message * update error msg * BitVector !?
1 parent a813a6e commit a1106b8

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

base/errorshow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ showerror(io::IO, ex) = show(io, ex)
3131

3232
show_index(io::IO, x::Any) = show(io, x)
3333
show_index(io::IO, x::Slice) = show_index(io, x.indices)
34-
show_index(io::IO, x::LogicalIndex) = show_index(io, x.mask)
34+
show_index(io::IO, x::LogicalIndex) = summary(io, x.mask)
3535
show_index(io::IO, x::OneTo) = print(io, "1:", x.stop)
3636
show_index(io::IO, x::Colon) = print(io, ':')
3737

test/arrayops.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,7 @@ end
28422842
b = IOBuffer()
28432843
showerror(b, err)
28442844
@test String(take!(b)) ==
2845-
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, Bool[1, 1]]"
2845+
"BoundsError: attempt to access 2×2 Matrix{Float64} at index [10, 2-element BitVector]"
28462846

28472847
# Also test : directly for custom types for which it may appear as-is
28482848
err = BoundsError(x, (10, :))

test/errorshow.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ let undefvar
297297
@test err_str == "BoundsError: attempt to access 3-element Vector{$Int} at index [-2, 1]"
298298
err_str = @except_str [5, 4, 3][1:5] BoundsError
299299
@test err_str == "BoundsError: attempt to access 3-element Vector{$Int} at index [1:5]"
300+
err_str = @except_str [5, 4, 3][trues(6,7)] BoundsError
301+
@test err_str == "BoundsError: attempt to access 3-element Vector{$Int} at index [6×7 BitMatrix]"
300302

301303
err_str = @except_str Bounded(2)[3] BoundsError
302304
@test err_str == "BoundsError: attempt to access 2-size Bounded at index [3]"

0 commit comments

Comments
 (0)