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

Error in dispatch? #38

Closed
sbromberger opened this issue Apr 12, 2017 · 3 comments
Closed

Error in dispatch? #38

sbromberger opened this issue Apr 12, 2017 · 3 comments

Comments

@sbromberger
Copy link

julia> using SimpleTraits

julia> abstract type AbFoo end

julia> struct Foo <: AbFoo
    x::Int
end

julia> @traitdef IsDirected{G<:AbFoo}

julia> @traitimpl IsDirected{G} <- is_directed(G)

julia> is_directed(x...) = error("nope")
is_directed (generic function with 1 method)

julia> is_directed(::Foo) = true
is_directed (generic function with 2 methods)

julia> is_directed(::Type{Foo}) = true
is_directed (generic function with 3 methods)

julia> is_directed(Foo)
true

julia> is_directed(AbFoo)
ERROR: nope
Stacktrace:
 [1] is_directed(::Type{T} where T) at ./REPL[6]:1

julia> @traitfn f(g::::IsDirected) = g.x
f (generic function with 2 methods)

julia> f(Foo(10))
ERROR: MethodError: no method matching is_directed(::Type{Foo})
The applicable method may be too new: running in world age 21602, while current world is 21607.
Closest candidates are:
  is_directed(::Type{Foo}) at REPL[8]:1 (method too new to be called from this world context.)
  is_directed(::Any...) at REPL[6]:1 (method too new to be called from this world context.)
  is_directed(::Foo) at REPL[7]:1 (method too new to be called from this world context.)
Stacktrace:
 [1] trait(...) at /Users/seth/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:186
 [2] f(::Foo) at /Users/seth/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:319

julia> is_directed(Foo)
true

julia> f(Foo(10))
ERROR: MethodError: no method matching is_directed(::Type{Foo})
The applicable method may be too new: running in world age 21602, while current world is 21608.
Closest candidates are:
  is_directed(::Type{Foo}) at REPL[15]:1 (method too new to be called from this world context.)
  is_directed(::Any...) at REPL[6]:1 (method too new to be called from this world context.)
  is_directed(::Foo) at REPL[7]:1 (method too new to be called from this world context.)
Stacktrace:
 [1] trait(...) at /Users/seth/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:186
 [2] f(::Foo) at /Users/seth/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:319

julia> is_directed(Foo)
true
@sbromberger
Copy link
Author

ref #39

@mauro3
Copy link
Owner

mauro3 commented Apr 18, 2017

Yes, this should be fixed with #39.

@mauro3
Copy link
Owner

mauro3 commented Apr 24, 2017

Fix. Ref #39 (comment)

@mauro3 mauro3 closed this as completed Apr 24, 2017
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

2 participants