Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -803,7 +803,7 @@ function getindex end
@eval getindex(A::Array, i1::Int, i2::Int, I::Int...) = (@_inline_meta; arrayref($(Expr(:boundscheck)), A, i1, i2, I...))

# Faster contiguous indexing using copyto! for UnitRange and Colon
function getindex(A::Array, I::UnitRange{Int})
function getindex(A::Array, I::AbstractUnitRange{<:Integer})
@_inline_meta
@boundscheck checkbounds(A, I)
lI = length(I)
Expand Down
23 changes: 23 additions & 0 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1280,3 +1280,26 @@ end
@test Int[0 t...; t... 0] == [0 1 2; 1 2 0]
@test_throws ArgumentError Int[t...; 3 4 5]
end

@testset "issue #39896, modified getindex " begin
a=collect(1:10)
ax=axes(a,1)
@test a==a[ax]
a=reshape(collect(1:100),(10,10))
@test a==a[ax,ax]
a=collect(1:10)
ax=Base.OneTo(8)
@test a[1:8]==a[ax]
a=reshape(collect(1:100),(10,10))
ay=Base.OneTo(7)
@test a[1:8,1:7]==a[ax,ay]
ax=UnitRange(1,10)
@test a[ax]==collect(1:10)
@test a[ax,ax]==reshape(collect(1:100),(10,10))
a=collect(1:BigInt(10))
ax=UnitRange(1,10)
@test a[ax]== collect(1:BigInt(10))
a=reshape(collect(1:BigInt(100)),(10,10))
@test a[ax,ax]==reshape(collect(1:BigInt(100)),(10,10))
end