ArrayInterface.jl
ArrayInterface.jl copied to clipboard
`getindex` method ambiguities with `AbstractTrees`, `Base`, and `OffsetArrays`
julia> using ArrayInterface, OffsetArrays, Test
julia> amb = Test.detect_ambiguities(ArrayInterface, OffsetArrays)
5-element Vector{Tuple{Method, Method}}:
(getindex(x::ArrayInterface.LazyAxis, i::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/axes.jl:293, getindex(r::AbstractUnitRange, s::Base.IdentityUnitRange{var"#s1"} where var"#s1"<:(AbstractUnitRange{var"#s2"} where var"#s2"<:Integer)) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513)
(getindex(r::ArrayInterface.OptionallyStaticUnitRange, s::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ranges.jl:296, getindex(r::AbstractUnitRange, s::OffsetArrays.IdOffsetRange) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513)
(getindex(r::ArrayInterface.OptionallyStaticUnitRange, s::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ranges.jl:296, getindex(r::AbstractUnitRange, s::Base.IdentityUnitRange{var"#s1"} where var"#s1"<:(AbstractUnitRange{var"#s2"} where var"#s2"<:Integer)) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513)
(getindex(x::AbstractArray, ::AbstractTrees.ImplicitRootState) in AbstractTrees at /home/chriselrod/.julia/packages/AbstractTrees/oHb1F/src/iteration.jl:103, getindex(A::ArrayInterface.AbstractArray2, args...) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ArrayInterface.jl:607)
(getindex(x::ArrayInterface.LazyAxis, i::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/axes.jl:293, getindex(r::AbstractUnitRange, s::OffsetArrays.IdOffsetRange) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513)
julia> for (a1,a2) ∈ amb
println(a1, "\n", a2, "\n")
end
getindex(x::ArrayInterface.LazyAxis, i::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/axes.jl:293
getindex(r::AbstractUnitRange, s::Base.IdentityUnitRange{var"#s1"} where var"#s1"<:(AbstractUnitRange{var"#s2"} where var"#s2"<:Integer)) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513
getindex(r::ArrayInterface.OptionallyStaticUnitRange, s::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ranges.jl:296
getindex(r::AbstractUnitRange, s::OffsetArrays.IdOffsetRange) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513
getindex(r::ArrayInterface.OptionallyStaticUnitRange, s::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ranges.jl:296
getindex(r::AbstractUnitRange, s::Base.IdentityUnitRange{var"#s1"} where var"#s1"<:(AbstractUnitRange{var"#s2"} where var"#s2"<:Integer)) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513
getindex(x::AbstractArray, ::AbstractTrees.ImplicitRootState) in AbstractTrees at /home/chriselrod/.julia/packages/AbstractTrees/oHb1F/src/iteration.jl:103
getindex(A::ArrayInterface.AbstractArray2, args...) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/ArrayInterface.jl:607
getindex(x::ArrayInterface.LazyAxis, i::AbstractUnitRange{var"#s15"} where var"#s15"<:Integer) in ArrayInterface at /home/chriselrod/.julia/packages/ArrayInterface/CYf5x/src/axes.jl:293
getindex(r::AbstractUnitRange, s::OffsetArrays.IdOffsetRange) in OffsetArrays at /home/chriselrod/.julia/packages/OffsetArrays/EYLoR/src/OffsetArrays.jl:513
So:
-
(::ArrayInterface.LazyAxis)[i::Base.IdentityUnitRange]
-
(::ArrayInterface.OptionallyStaticUnitRange)[::OffsetArrays.IdOffsetrange]
-
(::ArrayInterface.OptionallyStaticUnitRange)[::Base.IdentityUnitRange]
-
(::ArrayInterface.AbstractArray2)[::AbstractTrees.ImplicitRootState]
-
(ArrayInterface.LazyAxis)[OffsetArrays.IdOffsetRange]
This is partly due to a new type piracy in https://github.com/JuliaArrays/OffsetArrays.jl/pull/244, a patch might need https://github.com/JuliaLang/julia/pull/41224 merged first.
cc: @jishnub
As a temporary fix perhaps OffsetArrays
may limit its piracy to ranges defined in Base
. That should fix this, and it's unlikely that packages specifically depend on this behavior for range types that that they define.