Skip to content

Commit 7cbf55f

Browse files
authored
Widen RangeIndex from Int to BitInteger (#43262)
1 parent 48abb72 commit 7cbf55f

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

base/array.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const AbstractMatrix{T} = AbstractArray{T,2}
3636
Union type of [`AbstractVector{T}`](@ref) and [`AbstractMatrix{T}`](@ref).
3737
"""
3838
const AbstractVecOrMat{T} = Union{AbstractVector{T}, AbstractMatrix{T}}
39-
const RangeIndex = Union{Int, AbstractRange{Int}, AbstractUnitRange{Int}}
39+
const RangeIndex = Union{<:BitInteger, AbstractRange{<:BitInteger}}
4040
const DimOrInd = Union{Integer, AbstractUnitRange}
4141
const IntOrInd = Union{Int, AbstractUnitRange}
4242
const DimsOrInds{N} = NTuple{N,DimOrInd}

base/refpointer.jl

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ struct RefArray{T,A<:AbstractArray{T},R} <: Ref{T}
112112
end
113113
RefArray(x::AbstractArray{T}, i::Int, roots::Any) where {T} = RefArray{T,typeof(x),Any}(x, i, roots)
114114
RefArray(x::AbstractArray{T}, i::Int=1, roots::Nothing=nothing) where {T} = RefArray{T,typeof(x),Nothing}(x, i, nothing)
115+
RefArray(x::AbstractArray{T}, i::Integer, roots::Any) where {T} = RefArray{T,typeof(x),Any}(x, Int(i), roots)
116+
RefArray(x::AbstractArray{T}, i::Integer=1, roots::Nothing=nothing) where {T} = RefArray{T,typeof(x),Nothing}(x, Int(i), nothing)
115117
convert(::Type{Ref{T}}, x::AbstractArray{T}) where {T} = RefArray(x, 1)
116118

117119
function unsafe_convert(P::Union{Type{Ptr{T}},Type{Ptr{Cvoid}}}, b::RefArray{T})::P where T

test/subarray.jl

+25-3
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,15 @@ if testfull
288288
end
289289

290290
let B = copy(reshape(1:13^3, 13, 13, 13))
291-
@testset "spot checks: $oind" for oind in ((:,:,:),
291+
@testset "spot checks: $oind" for oind in (
292+
(:,:,:),
292293
(:,:,6),
293294
(:,6,:),
294295
(6,:,:),
295296
(:,3:7,:),
296297
(3:7,:,:),
297298
(3:7,6,:),
298299
(3:7,6,0x6),
299-
(6,UInt(3):UInt(7),3:7),
300300
(13:-2:1,:,:),
301301
([8,4,6,12,5,7],:,3:7),
302302
(6,CartesianIndex.(6,[8,4,6,12,5,7])),
@@ -307,7 +307,29 @@ let B = copy(reshape(1:13^3, 13, 13, 13))
307307
(3,reshape(2:11,5,2),4),
308308
(3,reshape(2:2:13,3,2),4),
309309
(view(1:13,[9,12,4,13,1]),2:6,4),
310-
([1:5 2:6 3:7 4:8 5:9], :, 3))
310+
([1:5 2:6 3:7 4:8 5:9], :, 3),
311+
)
312+
runsubarraytests(B, oind...)
313+
viewB = view(B, oind...)
314+
runviews(viewB, index5, index25, index125)
315+
end
316+
end
317+
318+
let B = copy(reshape(1:13^3, 13, 13, 13))
319+
@testset "spot checks (other BitIntegers): $oind" for oind in (
320+
(:,:,0x6),
321+
(:,0x00000006,:),
322+
(0x0006,:,:),
323+
(:,0x00000003:0x00000007,:),
324+
(0x0000000000000003:0x0000000000000007,:,:),
325+
(0x0003:0x0007,0x6,:),
326+
(6,UInt(3):UInt(7),3:7),
327+
(Int16(3):Int16(7),Int16(6),:),
328+
(CartesianIndex(0xD,0x6),UInt8[8,4,6,12,5,7]),
329+
(Int8(1),:,view(1:13,[9,12,4,13,1])),
330+
(view(1:13,Int16[9,12,4,13,1]),UInt8(2):UInt16(6),Int8(4)),
331+
(Int8[1:5 2:6 3:7 4:8 5:9],:,UInt64(3)),
332+
)
311333
runsubarraytests(B, oind...)
312334
viewB = view(B, oind...)
313335
runviews(viewB, index5, index25, index125)

0 commit comments

Comments
 (0)