Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ end
getindex(a::Array, r::AbstractUnitRange{Bool}) = getindex(a, to_index(r))

function getindex(A::Array, c::Colon)
lI = length(A)
lI = length(A)::Int
X = similar(A, lI)
if lI > 0
unsafe_copyto!(X, 1, A, 1, lI)
Expand Down
6 changes: 6 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ end
end
end

@testset "return type inference of `getindex(::Array, ::Colon)`" begin
f = a -> a[:]
@test Vector === Base.infer_return_type(f, Tuple{Array})
@test Vector{Float32} === Base.infer_return_type(f, Tuple{Array{Float32}})
end

struct Z26163 <: AbstractArray{Int,0}; end
Base.size(::Z26163) = ()
Base.getindex(::Z26163) = 0
Expand Down