Skip to content

Commit

Permalink
Fix display of operators in a pair (#30427)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0410 authored and JeffBezanson committed Jan 9, 2019
1 parent 19fedfb commit 16898e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
7 changes: 7 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16898e0

Please sign in to comment.