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
using Colors
st = Union{}[]
Base.show(stdout, MIME"image/svg+xml"(), st)
gives
julia> Base.show(stdout, MIME"image/svg+xml"(), st)
ERROR: MethodError:show(::Base.TTY, ::MIME{Symbol("image/svg+xml")}, ::Vector{Union{}}) is ambiguous. Candidates:show(io::IO, mime::MIME{Symbol("image/svg+xml")}, cs::AbstractVector{T}; max_swatches) where T<:TransparentColorin Colors at /Users/roger/.julia/packages/Colors/yDxFN/src/display.jl:41show(io::IO, mime::MIME{Symbol("image/svg+xml")}, cs::AbstractVector{T}; max_swatches) where T<:Colorin Colors at /Users/roger/.julia/packages/Colors/yDxFN/src/display.jl:35
Possible fix, define
show(::IO, ::MIME{Symbol("image/svg+xml")}, ::AbstractVector{Union{}})
Stacktrace:
[1] top-level scope
@ REPL[11]:1
because show(::IO, ::MIME{Symbol("image/svg+xml")}, ::AbstractVector{Union{}}) only relats to types in Base, so I think it should be defined here, but the questions how should we define it?
The text was updated successfully, but these errors were encountered:
One can construct infinitely many ambiguities, which, following this logic, should be resolved in Base:
julia>struct MyType1 end
julia>struct MyType2 end
julia> Base.:(+)(x::Vector{T}, y::Vector{T}) where {T <:MyType1} = x .+ y
julia> Base.:(+)(x::Vector{T}, y::Vector{T}) where {T <:MyType2} = x .+ y
julia> Union{}[] + Union{}[]
ERROR: MethodError:+(::Vector{Union{}}, ::Vector{Union{}}) is ambiguous. Candidates:+(x::Vector{T}, y::Vector{T}) where T<:MyType1in Main at REPL[3]:1+(x::Vector{T}, y::Vector{T}) where T<:MyType2in Main at REPL[4]:1
Possible fix, define
+(::Vector{Union{}}, ::Vector{Union{}})
Stacktrace:
[1] top-level scope
@ REPL[5]:1
I don't think adding random methods to Base is a solution that scales.
In Colors, this is overloaded for the
Color
type, but becauseUnion{} <: Color
, this will be ambiguous, e.ggives
because
show(::IO, ::MIME{Symbol("image/svg+xml")}, ::AbstractVector{Union{}})
only relats to types inBase
, so I think it should be defined here, but the questions how should we define it?The text was updated successfully, but these errors were encountered: