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

Ambiguous show method for Union{}[] #526

Closed
fonsp opened this issue Nov 1, 2022 · 3 comments
Closed

Ambiguous show method for Union{}[] #526

fonsp opened this issue Nov 1, 2022 · 3 comments
Labels

Comments

@fonsp
Copy link

fonsp commented Nov 1, 2022

Base.show(::IO, ::MIME{Symbol("image/svg+xml")}, ::Vector{Union{}}) is ambiguous, which leads to display errors when:

  1. Your environment supports SVG display (like Pluto, VS Code, Jupyter)
  2. You imported the Colors.jl package
  3. You output the object Union{}[]
~ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.0 (2022-08-17)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.8) pkg> activate --temp
  Activating new project at `/var/folders/v_/fhpj9jn151d4p9c2fdw2gv780000gn/T/jl_NNCbMf`

(jl_NNCbMf) pkg> add Colors
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/private/var/folders/v_/fhpj9jn151d4p9c2fdw2gv780000gn/T/jl_NNCbMf/Project.toml`
  [5ae59095] + Colors v0.12.8
    Updating `/private/var/folders/v_/fhpj9jn151d4p9c2fdw2gv780000gn/T/jl_NNCbMf/Manifest.toml`
  [3da002f7] + ColorTypes v0.11.4
  [5ae59095] + Colors v0.12.8
  [53c48c17] + FixedPointNumbers v0.8.4
  [189a3867] + Reexport v1.2.2
  [56f22d72] + Artifacts
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [9a3f8284] + Random
  [ea8e919c] + SHA v0.7.0
  [9e88b42a] + Serialization
  [2f01184e] + SparseArrays
  [10745b16] + Statistics
  [e66e0078] + CompilerSupportLibraries_jll v0.5.2+0
  [4536629a] + OpenBLAS_jll v0.3.20+0
  [8e850b90] + libblastrampoline_jll v5.1.1+0

julia> x = Union{}[]
Union{}[]

julia> using Colors

julia> show(stdout, MIME"image/svg+xml"(), x)
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<:TransparentColor in Colors at /Users/fons/.julia/packages/Colors/yDxFN/src/display.jl:41
  show(io::IO, mime::MIME{Symbol("image/svg+xml")}, cs::AbstractVector{T}; max_swatches) where T<:Color in Colors at /Users/fons/.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[8]:1
@fonsp
Copy link
Author

fonsp commented Nov 1, 2022

This could also be resolved by adding this to Colors.jl:

Base.showable(::MIME"image/svg+xml", ::Vector{Union{}}) = false

@johnnychen94
Copy link
Member

Hmmm, I'm not sure if Colors has the right to do this type piracy... Do you have any ideas on how to safely proceed this?

@fonsp
Copy link
Author

fonsp commented Dec 22, 2022

That's true... not sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants