diff --git a/base/subarray2.jl b/base/subarray2.jl index 7d618dcc62828..7a996a04d5e15 100644 --- a/base/subarray2.jl +++ b/base/subarray2.jl @@ -83,7 +83,7 @@ end # is just a matter of deleting the explicit call to copy. getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::ViewIndex...) = copy(sub(V, I...)) getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::AbstractArray{Bool,N}) = copy(sub(V, find(I))) # this could be much better optimized -getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union(Real, AbstractVector)...) = getindex(V, to_index(I)...) +getindex{T,N,P,IV}(V::SubArray{T,N,P,IV}, I::Union(Real, AbstractVector, Colon)...) = getindex(V, to_index(I)...) function setindex!{T,P,IV}(V::SubArray{T,1,P,IV}, v, I::AbstractArray{Bool,1}) length(I) == length(V) || throw(DimensionMismatch("logical vector must match array length")) diff --git a/test/subarray.jl b/test/subarray.jl index b3780b95afa75..723fc66b823e5 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -331,6 +331,8 @@ sA = sub(A, 1:2:3, 1:3:5, 1:2:8) @test sA[:] == A[1:2:3, 1:3:5, 1:2:8][:] # issue #8807 @test sub(sub([1:5;], 1:5), 1:5) == [1:5;] +# Test with mixed types +@test sA[:, Int16[1,2], 2.0] == [31 40; 33 42] # sub logical indexing #4763 A = sub([1:10;], 5:8)