AxisIndices.jl
AxisIndices.jl copied to clipboard
Problem with definition of `similar`
Currently (maybe nothing; something is very wrong):
- Fixes precompilation error arising from ambiguous dispatch (has a formal name that I forget, but basically when two methods only differ in argument types
::Tuple{AbstractType1}and::Tuple{AbstractType2}whereAbstractType1 <: AbstractType2so you think one supersedes the other, but what you really want is::Tuple{<:AbstractType1}and::Tuple{<:AbstractType2}to make the dispatch system happy)
Want:
- to fix #62
I've "fixed" the problem. But I'm overriding a function in Base without understanding why it acts the way it does. In Base, base/abstractarray.jl:753 defines to_shape(r::AbstractUnitRange) = r, but I don't understand why it's that way instead of to_shape(r::AbstractUnitRange) = length(r).
I probably don't understand this because I don't understand when a base array would ever try to use AbstractUnitArray in the dims argument. In fact, when I try to use Base's definition of this method via similar (via similar(Array{Float64}, 1:3, 1:4)), I get a MethodError. I'm evidently missing something veeeery obvious, because one of the "closest candidates" is similar(::Type{T}, ::Union{Integer, AbstractUnitRange}...) where T<:AbstractArray at abstractarray.jl:777.