diff --git a/base/deprecated.jl b/base/deprecated.jl index 598e1acc16132..35da70e7a5a41 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1146,6 +1146,10 @@ for (dep, f, op) in [(:sumabs!, :sum!, :abs), end end +# #19719 +@deprecate getindex(t::Tuple, r::AbstractArray) getindex(t, vec(r)) +@deprecate getindex(t::Tuple, b::AbstractArray{Bool}) getindex(t, vec(b)) + @deprecate airy(z::Number) airyai(z) @deprecate airyx(z::Number) airyaix(z) @deprecate airyprime(z::Number) airyaiprime(z) diff --git a/base/tuple.jl b/base/tuple.jl index 04e6e1f6eb131..52507335f3da8 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -15,8 +15,8 @@ endof(t::Tuple) = length(t) size(t::Tuple, d) = d==1 ? length(t) : throw(ArgumentError("invalid tuple dimension $d")) getindex(t::Tuple, i::Int) = getfield(t, i) getindex(t::Tuple, i::Real) = getfield(t, convert(Int, i)) -getindex(t::Tuple, r::AbstractArray) = tuple([t[ri] for ri in r]...) -getindex(t::Tuple, b::AbstractArray{Bool}) = getindex(t,find(b)) +getindex{T}(t::Tuple, r::AbstractArray{T,1}) = tuple([t[ri] for ri in r]...) +getindex(t::Tuple, b::AbstractArray{Bool,1}) = length(b) == length(t) ? getindex(t,find(b)) : throw(BoundsError(t, b)) ## iterating ## diff --git a/test/tuple.jl b/test/tuple.jl index bbf2c78bed94e..bd8963c361cb1 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -170,3 +170,11 @@ for n = 0:20 @test t[i] == i end end + +# issue #19719 +@test_throws BoundsError (1,2,3)[falses(4)] +@test_throws BoundsError (1,2,3)[[false,false,true,true]] +@test_throws BoundsError (1,2,3)[trues(2)] +@test_throws BoundsError (1,2,3)[falses(2)] +@test_throws BoundsError ()[[false]] +@test_throws BoundsError ()[[true]]