Skip to content

Commit 55f48e0

Browse files
committed
Fix printing for term operators that could be both unary and binary
Fix #512
1 parent ba96757 commit 55f48e0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/types.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,14 @@ end
778778

779779
function show_call(io, f, args)
780780
fname = istree(f) ? Symbol(repr(f)) : nameof(f)
781-
binary = Base.isbinaryoperator(fname)
782-
if binary
783-
for (i, t) in enumerate(args)
784-
i != 1 && print(io, " $fname ")
785-
print_arg(io, t, paren=true)
786-
end
781+
len_args = length(args)
782+
if Base.isunaryoperator(fname) && len_args == 1
783+
print(io, "$fname")
784+
print_arg(io, first(args), paren=true)
785+
elseif Base.isbinaryoperator(fname) && len_args == 2
786+
print_arg(io, first(args), paren=true)
787+
print(io, " $fname ")
788+
print_arg(io, last(args), paren=true)
787789
else
788790
if issym(f)
789791
Base.show_unquoted(io, nameof(f))

0 commit comments

Comments
 (0)