Skip to content

Commit

Permalink
Merge pull request JuliaLang#11416 from fcard/patch-1
Browse files Browse the repository at this point in the history
RFC: Fixes JuliaLang#11413
  • Loading branch information
simonster committed May 24, 2015
2 parents b85ede9 + ed992a6 commit 40f57ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,8 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
if is(head, :tuple) && nargs == 1; print(io, ','); end
head !== :row && print(io, cl)

# function declaration (like :call but always printed with parens)
# (:calldecl is a "fake" expr node created when we find a :function expr)
elseif head == :calldecl && nargs >= 1
show_call(io, head, args[1], args[2:end], indent)

# function call
elseif haskey(expr_calls, head) && nargs >= 1 # :call/:ref/:curly
elseif head == :call && nargs >= 1
func = args[1]
func_prec = operator_precedence(func)
func_args = args[2:end]
Expand Down Expand Up @@ -535,11 +530,15 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
show_enclosed_list(io, op, func_args, ",", cl, indent)
end

# normal function (i.e. "f(x,y)" or "A[x,y]")
# normal function (i.e. "f(x,y)")
else
show_call(io, head, func, func_args, indent)
end

# other call-like expressions ("A[1,2]", "T{X,Y}")
elseif haskey(expr_calls, head) && nargs >= 1 # :ref/:curly/:calldecl
show_call(io, head, ex.args[1], ex.args[2:end], indent)

# comprehensions
elseif (head === :typed_comprehension || head === :typed_dict_comprehension) && length(args) == 3
isdict = (head === :typed_dict_comprehension)
Expand Down
5 changes: 5 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,8 @@ end

# issue #9865
@test ismatch(r"^Set\(\[.+….+\]\)$", replstr(Set(1:100)))

# issue 11413
@test string(:(*{1,2})) == "*{1,2}"
@test string(:(*{1,x})) == "*{1,x}"
@test string(:(-{x})) == "-{x}"

0 comments on commit 40f57ff

Please sign in to comment.