Skip to content

Commit 4ffdc70

Browse files
authored
Limit varargs reshape method to integer AbstractUnitRanges (#365)
1 parent 1501e52 commit 4ffdc70

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/OffsetArrays.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ _similar_axes_or_length(A, T, ax::I, ::I) where {I} = similar(A, T, map(_indexle
348348
_similar_axes_or_length(AT, ax::I, ::I) where {I} = similar(AT, map(_indexlength, ax))
349349

350350
# reshape accepts a single colon
351-
Base.reshape(A::AbstractArray, inds::OffsetAxis...) = reshape(A, inds)
351+
# this method is limited to AbstractUnitRange{<:Integer} to avoid method overwritten errors if Base defines the same,
352+
# see https://github.com/JuliaLang/julia/pull/56850
353+
Base.reshape(A::AbstractArray, inds::Union{Integer, Colon, AbstractUnitRange{<:Integer}}...) = reshape(A, inds)
352354
function Base.reshape(A::AbstractArray, inds::Tuple{Vararg{OffsetAxis}})
353355
AR = reshape(no_offset_view(A), map(_indexlength, inds))
354356
O = OffsetArray(AR, map(_offset, axes(AR), inds))

0 commit comments

Comments
 (0)