You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.
i was trying to do this, but obviously i get the following issue:
julia> module X
using Traits
export TR
@traitdef TR{T} begin
fun(T) -> Number
end
end
This warning is ok:
WARNING: Method definition func_for_method(Method, Any, Any) in module Inference at inference.jl:610 overwritten in module Traits at /local/rra/HEJU/julia_pkg/Traits.jl/src/base_fixes.jl:8.
WARNING: Method definition eltype(Type{Base.Associative{#K<:Any, #V<:Any}}) in module Base at dict.jl:240 overwritten in module Traits at /local/rra/HEJU/julia_pkg/Traits.jl/src/base_fixes.jl:20.
endof ok-warnings.
X
julia> module Y
using Traits
using X
@traitimpl TR{Int64} begin
fun(x::Int64) = 3x
end
end
**** Checking X.TR{T}: Could not instantiate instance for type encoding the trait X.TR{Int64}.
This usually indicates that something is amiss with the @traitdef
or that one of the generic functions is not defined.
The error was: UndefVarError(:fun)
ERROR: AssertionError: istrait(TR{Int64},verbose=true)
How can i do this?
Thanks
(Edited by @mauro3: added tripple back-ticks. Also note that with quoting macro I meant enclosing them with back-ticks and not just a single back-tick in front of them.)
The text was updated successfully, but these errors were encountered:
It should work, but doesn't... This workaround works:
julia> module X
using Traits
export TR
fun(x)= 1
@traitdef TR{T} begin
fun(T) -> Number
end
end
X
julia> module Y
using Traits
using X
@traitimpl TR{Int64} begin
fun(x::Int64) = 3x
end
end
Maybe an explicit function def should be used? Like so:
julia> module X
using Traits
export TR
function fun end # not sure whether an explicit function-def
@traitdef TR{T} begin
fun(T) -> Number
end
end
But this does not work either. However, in light of JuliaLang/julia#14636, I'm not sure how to implement this.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
i was trying to do this, but obviously i get the following issue:
How can i do this?
Thanks
(Edited by @mauro3: added tripple back-ticks. Also note that with quoting macro I meant enclosing them with back-ticks and not just a single back-tick in front of them.)
The text was updated successfully, but these errors were encountered: