-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Convert dispatch depends on the method order? #12939
Labels
types and dispatch
Types, subtyping and method dispatch
Comments
reduction: julia> begin
abstract Abs
type Foo <: Abs; end
type Bar; val::Int64; end
type Baz; val::Int64; end
fb{T}(::Type{T}, x::T) = T(3) # this definition is critical for causing
fb{T <: Abs}(::Type{Bar}, x::T) = Bar(2) # this method to sort incorrectly
fb(::Type{Bar}, x) = Bar(1) # the rest don't matter for this example
fb(::Type{Baz}, x) = Baz(1) # this method helps
fb{T <: Abs}(::Type{Baz}, x::T) = Baz(2) # this method to end up in the place expected by the author
end
fb (generic function with 5 methods)
julia> methods(fb)
# 5 methods for generic function "fb":
fb(::Type{Bar}, x) at none:4
fb{T<:Abs}(::Type{Baz}, x::T<:Abs) at none:8
fb(::Type{Baz}, x) at none:7
fb{T}(::Type{T}, x::T) at none:2
fb{T<:Abs}(::Type{Bar}, x::T<:Abs) at none:3
julia> fb(Baz,Foo())
Baz(2)
julia> fb(Bar,Foo())
Bar(1) |
i assume this'll be fixed by #8974 |
Specificity issue, not fixed yet. |
This is fixed now. Will add a test. |
JeffBezanson
added a commit
that referenced
this issue
Apr 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using a sample code:
I get this on julia 0.3.11:
and this on latest 0.4:
Is this supposed to happen? Note that the only difference between Bar and Baz is in the method definition order and it only happens with
convert
The text was updated successfully, but these errors were encountered: