Skip to content

Commit 8407e95

Browse files
authored
prevent type piracy on Base.merge (#37)
1 parent 5950d1d commit 8407e95

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/crayon.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,9 @@ end
275275

276276
Base.:*(a::Crayon, b::Crayon) = merge(a, b)
277277

278-
function Base.merge(toks::Crayon...)
279-
if length(toks) == 0
280-
return Crayon()
281-
end
282-
tok = toks[1]
283-
for i in 2:length(toks)
284-
tok = merge(tok, toks[i])
278+
function Base.merge(tok::Crayon, toks::Crayon...)
279+
for tok2 in toks
280+
tok = merge(tok, tok2)
285281
end
286282
return tok
287283
end

test/runtests.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pop!(cs) # State change: fg = default
110110
@test string(cs) == string(Crayon(foreground = :default))
111111

112112
# Merge
113-
@test string(merge()) == ""
114113
@test string(merge(Crayon(foreground = :blue, background = :red))) == string(Crayon(foreground = :blue, background = :red))
115114
@test string(merge(Crayon(foreground = :blue), Crayon(background = :red))) == string(Crayon(foreground = :blue, background = :red))
116115
@test string(merge(Crayon(foreground = :blue), Crayon(background = :red), Crayon(bold = true))) == string(Crayon(foreground = :blue, background = :red, bold = true))

0 commit comments

Comments
 (0)