Skip to content

Commit 1d2dfb7

Browse files
committed
fix 1-arg printing when op is also a binaryoperator
1 parent 8f933e2 commit 1d2dfb7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ function Base.show(io::IO, t::Term)
320320
if binary
321321
get(io, :paren, false) && Base.printstyled(io, "(",color=color)
322322
for i = 1:length(args)
323+
length(args) == 1 && Base.printstyled(io, fname, color=color)
323324
Base.printstyled(IOContext(io, :paren => true),
324325
args[i], color=color)
325326
i != length(args) && Base.printstyled(io, " $fname ", color=color)

test/basics.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,10 @@ end
8787
@test substitute(sin(a+b), Dict(a=>1)) == sin(1+b)
8888
@test substitute(a+b, Dict(a=>1, b=>3)) |> simplify == 4
8989
end
90+
91+
@testset "printing" begin
92+
@syms a b
93+
@test repr(a+b) == "a + b"
94+
@test repr(-a) == "-a"
95+
@test repr(-a + 3) == "3 + (-a)"
96+
end

0 commit comments

Comments
 (0)