KristofferC / Crayons.jl

Colored and styled strings for terminals.
Other
150 stars 14 forks source link

Base.merge() splatting issue #36

Closed tomyun closed 4 years ago

tomyun commented 4 years ago

Not sure if this is subject to type piracy, but quite puzzling when I first saw a Crayon popping out of nowhere.

Normal behavior of Base.merge() before Crayons got imported:

julia> merge()
ERROR: MethodError: no method matching merge()
Closest candidates are:
  merge(::AbstractDict, ::AbstractDict...) at abstractdict.jl:286
  merge(::Function, ::AbstractDict, ::AbstractDict...) at abstractdict.jl:316
  merge(::NamedTuple{(),T} where T<:Tuple, ::NamedTuple) at namedtuple.jl:233
  ...
Stacktrace:
 [1] top-level scope at REPL[1]:1

After:

julia> import Crayons

julia> merge()

julia> ans |> typeof
Crayons.Crayon

It comes from splatting Base.merge(toks::Crayon...). https://github.com/KristofferC/Crayons.jl/blob/5950d1d2eac171c06139d99e5f600a4d41ee5b9b/src/crayon.jl#L278

KristofferC commented 4 years ago

Thanks: https://github.com/KristofferC/Crayons.jl/pull/37.