Skip to content

Commit

Permalink
print parentheses around dotted operators, fix #26517 (#26531)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored and JeffBezanson committed Mar 20, 2018
1 parent aa7b3f9 commit 2723d74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ end
# show a normal (non-operator) function call, e.g. f(x, y) or A[z]
function show_call(io::IO, head, func, func_args, indent)
op, cl = expr_calls[head]
if (isa(func, Symbol) && func !== :(:)) ||
if (isa(func, Symbol) && func !== :(:) && !(head === :. && isoperator(func))) ||
(isa(func, Expr) && (func.head == :. || func.head == :curly))
show_unquoted(io, func, indent)
else
Expand Down
3 changes: 3 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ end
@test repr(:(f.(X, Y))) == ":(f.(X, Y))"
@test repr(:(f.(X))) == ":(f.(X))"
@test repr(:(f.())) == ":(f.())"
# broadcasted operators (#26517)
@test_repr ":(y .= (+).(x, (*).(3, sin.(x))))"
@test repr(:(y .= (+).(x, (*).(3, (sin).(x))))) == ":(y .= (+).(x, (*).(3, sin.(x))))"

# pretty-printing of other `.` exprs
test_repr("a.b")
Expand Down

1 comment on commit 2723d74

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.