Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getindex method ambiguities with AbstractTrees, Base, and OffsetArrays #170

Closed
chriselrod opened this issue Jun 18, 2021 · 2 comments
Closed

Comments

@chriselrod
Copy link
Collaborator

chriselrod commented Jun 18, 2021

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:

  1. (::ArrayInterface.LazyAxis)[i::Base.IdentityUnitRange]
  2. (::ArrayInterface.OptionallyStaticUnitRange)[::OffsetArrays.IdOffsetrange]
  3. (::ArrayInterface.OptionallyStaticUnitRange)[::Base.IdentityUnitRange]
  4. (::ArrayInterface.AbstractArray2)[::AbstractTrees.ImplicitRootState]
  5. (ArrayInterface.LazyAxis)[OffsetArrays.IdOffsetRange]
@chriselrod chriselrod changed the title Ambiguities with OffsetArrays getindex method ambiguities with OffsetArrays Jun 18, 2021
@chriselrod chriselrod changed the title getindex method ambiguities with OffsetArrays getindex method ambiguities with AbstractTrees, Base, and OffsetArrays Jun 18, 2021
@johnnychen94
Copy link
Member

This is partly due to a new type piracy in JuliaArrays/OffsetArrays.jl#244, a patch might need JuliaLang/julia#41224 merged first.

cc: @jishnub

@jishnub
Copy link
Member

jishnub commented Jun 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants