In a probabilistic programming package I am working on, I have a 
RandVarSymbolic{T} type.
The following promotion rules (should) state basically that a type T and 
and a RandVarSymbolic parameterised on that T should promote to the 
RandVarSymbolic{T}.
In the special case when I have different types but they are both subtypes 
of Real, I want to promote these subtypes first.

promote_rule{T<:Real}(::Type{T}, ::Type{RandVarSymbolic{T}}) = 
RandVarSymbolic{T}
promote_rule{T}(::Type{T}, ::Type{RandVarSymbolic{T}}) = RandVarSymbolic{T}
promote_rule{T1<:Real, T2<:Real}(::Type{T1}, ::Type{RandVarSymbolic{T2}}) =
  RandVarSymbolic{promote_type(T1,T2)}


I get the warning

Warning: New definition 
    promote_rule(Type{T1<:Real},Type{RandVarSymbolic{T2<:Real}}) at 
/home/zenna/.julia/v0.3/Sigma/src/randvar/randvarsymbolic.jl:50
is ambiguous with: 
    promote_rule(Type{T},Type{RandVarSymbolic{T}}) at 
/home/zenna/.julia/v0.3/Sigma/src/randvar/randvarsymbolic.jl:42.
To fix, define 
    promote_rule(Type{_<:Real},Type{RandVarSymbolic{_<:Real}})
before the new definition.

The error makes sense, except I believe I have accounted for this with the 
first rule - the types for the method the warning is asking me to specify 
are the same as what I wrote.

Any idea of what's going on here?

Zenna

Reply via email to