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/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function eachindex(A::AbstractArray, B::AbstractArray...)
@inline
eachindex(IndexStyle(A,B...), A, B...)
end
eachindex(::IndexLinear, A::Union{Array, Memory}) = unchecked_oneto(length(A))
eachindex(::IndexLinear, A::Union{Array, Memory}) = unchecked_oneto(length(A)::Int)
eachindex(::IndexLinear, A::AbstractArray) = (@inline; oneto(length(A)))
eachindex(::IndexLinear, A::AbstractVector) = (@inline; axes1(A))
function eachindex(::IndexLinear, A::AbstractArray, B::AbstractArray...)
Expand Down
7 changes: 7 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,13 @@ let A = zeros(Int, 2, 2), B = zeros(Float64, 2, 2)
end
end

@testset "return type inference of linear `eachindex` for `Array` and `Memory`" begin
f = a -> eachindex(IndexLinear(), a)
for typ in (Array, Memory, Union{Array, Memory})
@test isconcretetype(Base.infer_return_type(f, Tuple{typ}))
end
end

# issue #14482
@inferred map(Int8, Int[0])

Expand Down