Skip to content

Commit

Permalink
Merge pull request JuliaLang#36359 from JuliaLang/rf/fix-bitvector-de…
Browse files Browse the repository at this point in the history
…leteat

deleteat!(::BitVector, inds) : check bounds for the first passed index
  • Loading branch information
mbauman committed Jun 25, 2020
2 parents 5bb1053 + ca4a895 commit 29e1454
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,11 @@ function deleteat!(B::BitVector, inds)
n = new_l = length(B)
y = iterate(inds)
y === nothing && return B
n == 0 && throw(BoundsError(B, inds))

Bc = B.chunks

(p, s) = y
checkbounds(B, p)
q = p+1
new_l -= 1
y = iterate(inds, s)
Expand Down
2 changes: 2 additions & 0 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ timesofar("indexing")
b1 = bitrand(v1)
@test_throws ArgumentError deleteat!(b1, [1, 1, 2])
@test_throws BoundsError deleteat!(b1, [1, length(b1)+1])
@test_throws BoundsError deleteat!(b1, [length(b1)+rand(1:100)])
@test_throws BoundsError deleteat!(bitrand(1), [-1, 0, 1])

@test_throws BoundsError deleteat!(BitVector(), 1)
@test_throws BoundsError deleteat!(BitVector(), [1])
Expand Down

0 comments on commit 29e1454

Please sign in to comment.