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

Problem with definition of similar #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

grahamas
Copy link

@grahamas grahamas commented Jan 8, 2021

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} where AbstractType1 <: AbstractType2 so you think one supersedes the other, but what you really want is ::Tuple{<:AbstractType1} and ::Tuple{<:AbstractType2} to make the dispatch system happy)

Want:

@grahamas
Copy link
Author

grahamas commented Jan 8, 2021

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.

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

Successfully merging this pull request may close these issues.

similar StackOverflowError
1 participant