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
Suppose a type T is defined in a package. Further suppose that S is some type not owned by the same package, and T <: S. Defining either of the following method signatures should be forbidden, because it causes dispatch ambiguity for perfectly valid promote_rule definitions from third-party packages:
NB: Base doesn't respect this rule, though perhaps this is OK/less bad, given that Base is an implicit dependency of everything anyway. Examples:
promote_rule(::Type{BigInt}, ::Type{<:Integer}) in Base.GMP at gmp.jl:460
promote_rule(::Type{BigFloat}, ::Type{<:Real}) in Base.MPFR at mpfr.jl:366
promote_rule(::Type{Bool}, ::Type{T}) where T<:Number @ Base bool.jl:4
promote_rule(::Type{<:AbstractIrrational}, ::Type{T}) where T<:Real @ Base irrationals.jl:47
promote_rule(::Type{S}, ::Type{T}) where {S<:AbstractIrrational, T<:Number} @ Base irrationals.jl:48
Suppose a type
T
is defined in a package. Further suppose thatS
is some type not owned by the same package, andT <: S
. Defining either of the following method signatures should be forbidden, because it causes dispatch ambiguity for perfectly validpromote_rule
definitions from third-party packages:NB:
Base
doesn't respect this rule, though perhaps this is OK/less bad, given thatBase
is an implicit dependency of everything anyway. Examples:Example code for ambiguity errors:
The text was updated successfully, but these errors were encountered: