Skip to content

Commit d42abc6

Browse files
authored
Fix Base.show(io::IO, b::Binding) for e.g. :(:) or :(==) (#61043)
Fixes JuliaDocs/Documenter.jl#2844
1 parent 9c1e1fa commit d42abc6

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

base/docs/bindings.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ function Base.show(io::IO, b::Binding)
2828
if b.mod === Base.active_module()
2929
print(io, b.var)
3030
else
31-
print(io, b.mod, '.', Base.isoperator(b.var) ? ":" : "", b.var)
31+
print(io, b.mod, '.')
32+
if Base.isoperator(b.var)
33+
# ensures symbols are quoted right, so e.g. :(==), :(:), :+ or :-
34+
show(io, b.var)
35+
else
36+
# print ordinary identifiers without any quoting
37+
print(io, b.var)
38+
end
3239
end
3340
end
3441

test/docs.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,10 @@ let x = Binding(Main, :+)
12961296
@test Meta.parse(string(x)) == :(Base.:+)
12971297
end
12981298

1299+
let x = Binding(Main, :(:))
1300+
@test Meta.parse(string(x)) == :(Base.:(:))
1301+
end
1302+
12991303
let x = Binding(Meta, :parse)
13001304
@test Meta.parse(string(x)) == :(Base.Meta.parse)
13011305
end

0 commit comments

Comments
 (0)