Skip to content

Commit

Permalink
Merge pull request #15527 from JuliaLang/yyc/show-vcat
Browse files Browse the repository at this point in the history
Fix printing of Expr(:vcat)
  • Loading branch information
yuyichao committed Mar 19, 2016
2 parents b4637e3 + e8d2b02 commit 05bdbb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
# list (i.e. "(1,2,3)" or "[1,2,3]")
elseif haskey(expr_parens, head) # :tuple/:vcat/:cell1d
op, cl = expr_parens[head]
if head === :vcat && !isempty(args) && is_expr(args[1], :row)
if head === :vcat
sep = ";"
elseif head === :hcat || head === :row
sep = " "
Expand All @@ -581,7 +581,9 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
end
head !== :row && print(io, op)
show_list(io, args, sep, indent)
if is(head, :tuple) && nargs == 1; print(io, ','); end
if (head === :tuple || head === :vcat) && nargs == 1
print(io, sep)
end
head !== :row && print(io, cl)

# function call
Expand Down
6 changes: 6 additions & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,9 @@ A = reshape(1:16,4,4)
@test replstr(Tridiagonal(diag(A,-1),diag(A),diag(A,+1))) == "4x4 Tridiagonal{$Int}:\n 1 5 ⋅ ⋅\n 2 6 10 ⋅\n ⋅ 7 11 15\n ⋅ ⋅ 12 16"
@test replstr(UpperTriangular(A)) == "4x4 UpperTriangular{$Int,Array{$Int,2}}:\n 1 5 9 13\n ⋅ 6 10 14\n ⋅ ⋅ 11 15\n ⋅ ⋅ ⋅ 16"
@test replstr(LowerTriangular(A)) == "4x4 LowerTriangular{$Int,Array{$Int,2}}:\n 1 ⋅ ⋅ ⋅\n 2 6 ⋅ ⋅\n 3 7 11 ⋅\n 4 8 12 16"

# Issue #15525, printing of vcat
@test sprint(show, :([a;])) == ":([a;])"
@test sprint(show, :([a;b])) == ":([a;b])"
@test_repr "[a;]"
@test_repr "[a;b]"

0 comments on commit 05bdbb0

Please sign in to comment.