diff --git a/base/array.jl b/base/array.jl index 8954f3e5b9d23..bd6807853c93e 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1352,9 +1352,9 @@ function _deleteat!(a::Vector, inds, dltd=Nowhere()) n = length(a) y = iterate(inds) y === nothing && return a - n == 0 && throw(BoundsError(a, inds)) (p, s) = y - p <= n && push!(dltd, @inbounds a[p]) + checkbounds(a, p) + push!(dltd, @inbounds a[p]) q = p+1 while true y = iterate(inds, s) diff --git a/test/arrayops.jl b/test/arrayops.jl index 9ecd9f4a0bab2..e8acde4c8826e 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -1446,11 +1446,15 @@ end @test deleteat!(a, [1,3,5,7:10...]) == [2,4,6] @test_throws BoundsError deleteat!(a, 13) @test_throws BoundsError deleteat!(a, [1,13]) - @test_throws ArgumentError deleteat!(a, [5,3]) + @test_throws ArgumentError deleteat!(a, [3,2]) # not sorted @test_throws BoundsError deleteat!(a, 5:20) @test_throws BoundsError deleteat!(a, Bool[]) @test_throws BoundsError deleteat!(a, [true]) @test_throws BoundsError deleteat!(a, falses(11)) + @test_throws BoundsError deleteat!(a, [0]) + @test_throws BoundsError deleteat!(a, [4]) + @test_throws BoundsError deleteat!(a, [5]) + @test_throws BoundsError deleteat!(a, [5, 3]) @test_throws BoundsError deleteat!([], 1) @test_throws BoundsError deleteat!([], [1])