Skip to content

Commit

Permalink
Show dot expressions without parentheses (JuliaLang#31074)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregPlowman authored and JeffBezanson committed Feb 16, 2019
1 parent a00e3f1 commit a44b421
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 @@ -1121,7 +1121,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
item = args[1]
# field
field = unquoted(args[2])
parens = !is_quoted(item) && !(item isa Symbol && isidentifier(item))
parens = !is_quoted(item) && !(item isa Symbol && isidentifier(item)) && !Meta.isexpr(item, :(.))
parens && print(io, '(')
show_unquoted(io, item, indent)
parens && print(io, ')')
Expand Down
3 changes: 3 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1462,3 +1462,6 @@ end
# issue #30927
Z = Array{Float64}(undef,0,0)
@test eval(Meta.parse(repr(Z))) == Z

# issue #31065, do not print parentheses for nested dot expressions
@test sprint(Base.show_unquoted, :(foo.x.x)) == "foo.x.x"

0 comments on commit a44b421

Please sign in to comment.