Skip to content

Instantly share code, notes, and snippets.

@maximsch2
Created September 4, 2015 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximsch2/6557c1805325673531c3 to your computer and use it in GitHub Desktop.
Save maximsch2/6557c1805325673531c3 to your computer and use it in GitHub Desktop.
Julia 0.4 method dispatch bug?
abstract Abs
type Foo <: Abs
end
type Bar
val::Int64
end
type Baz
val::Int64
end
import Base.convert
convert{T <: Abs}(::Type{Bar}, x::T) = Bar(2)
convert(::Type{Bar}, x) = Bar(1)
convert(::Type{Baz}, x) = Baz(1)
convert{T <: Abs}(::Type{Baz}, x::T) = Baz(2)
bar(y) = convert(Bar, y)
baz(y) = convert(Baz, y)
@show bar(Foo())
@show baz(Foo())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment