Skip to content

Commit f5cd050

Browse files
authored
fix indexing for OneTo on v1.7 (#249)
* fix indexing for OneTo on v1.7 * remove unnecessary unionall in vararg * version bump to v1.10.2
1 parent 4bd33fb commit f5cd050

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "OffsetArrays"
22
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3-
version = "1.10.1"
3+
version = "1.10.2"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/OffsetArrays.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ end
509509
@inline _boundscheck_return(r, s) = (@boundscheck checkbounds(r, s); s)
510510

511511
for OR in [:IIUR, :IdOffsetRange]
512-
for R in [:StepRange, :StepRangeLen, :LinRange, :UnitRange, :(Base.OneTo)]
512+
for R in [:StepRange, :StepRangeLen, :LinRange, :UnitRange]
513513
@eval @inline Base.getindex(r::$R, s::$OR) = _boundscheck_index_retaining_axes(r, s)
514514
end
515515

@@ -518,6 +518,10 @@ for OR in [:IIUR, :IdOffsetRange]
518518
_boundscheck_index_retaining_axes(r, s)
519519
end
520520
end
521+
Base.getindex(r::Base.OneTo, s::IdOffsetRange) = _boundscheck_index_retaining_axes(r, s)
522+
if VERSION < v"1.7.0-beta2"
523+
Base.getindex(r::Base.OneTo, s::IIUR) = _boundscheck_index_retaining_axes(r, s)
524+
end
521525

522526
# These methods are added to avoid ambiguities with Base.
523527
# The ones involving Base types should be ported to Base and version-limited here
@@ -628,9 +632,9 @@ no_offset_view(a::Array) = a
628632
no_offset_view(i::Number) = i
629633
no_offset_view(A::AbstractArray) = _no_offset_view(axes(A), A)
630634
_no_offset_view(::Tuple{}, A::AbstractArray{T,0}) where T = A
631-
_no_offset_view(::Tuple{<:Base.OneTo,Vararg{<:Base.OneTo}}, A::AbstractArray) = A
635+
_no_offset_view(::Tuple{Base.OneTo, Vararg{Base.OneTo}}, A::AbstractArray) = A
632636
# the following method is needed for ambiguity resolution
633-
_no_offset_view(::Tuple{<:Base.OneTo,Vararg{<:Base.OneTo}}, A::AbstractUnitRange) = A
637+
_no_offset_view(::Tuple{Base.OneTo, Vararg{Base.OneTo}}, A::AbstractUnitRange) = A
634638
_no_offset_view(::Any, A::AbstractArray) = OffsetArray(A, Origin(1))
635639
_no_offset_view(::Any, A::AbstractUnitRange) = UnitRange(A)
636640

0 commit comments

Comments
 (0)