diff --git a/base/show.jl b/base/show.jl index 72d45c82e6895..b2bb112aa7206 100644 --- a/base/show.jl +++ b/base/show.jl @@ -576,6 +576,7 @@ has_tight_type(p::Pair) = typeof(p.second) == typeof(p).parameters[2] isdelimited(io::IO, x) = true +isdelimited(io::IO, x::Function) = !isoperator(Symbol(x)) # !isdelimited means that the Pair is printed with "=>" (like in "1 => 2"), # without its explicit type (like in "Pair{Integer,Integer}(1, 2)") diff --git a/test/show.jl b/test/show.jl index be47c0cdd3103..3c7fb444c4606 100644 --- a/test/show.jl +++ b/test/show.jl @@ -1007,6 +1007,13 @@ end # issue #28327 d = Dict(Pair{Integer,Integer}(1,2)=>Pair{Integer,Integer}(1,2)) @test showstr(d) == "Dict((1=>2)=>(1=>2))" # correct parenthesis + + # issue #29536 + d = Dict((+)=>1) + @test showstr(d) == "Dict((+)=>1)" + + d = Dict("+"=>1) + @test showstr(d) == "Dict(\"+\"=>1)" end @testset "alignment for pairs" begin # (#22899)