From e8d2b02fb9876107fa1c42593f1bcdab54a231b1 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Tue, 15 Mar 2016 21:48:42 -0400 Subject: [PATCH] Fix printing of Expr(:vcat) Closes #15525 --- base/show.jl | 6 ++++-- test/show.jl | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/base/show.jl b/base/show.jl index 229a9b62c7e85..a3f4002587348 100644 --- a/base/show.jl +++ b/base/show.jl @@ -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 = " " @@ -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 diff --git a/test/show.jl b/test/show.jl index 175e52d1bf8fa..23334e19c5758 100644 --- a/test/show.jl +++ b/test/show.jl @@ -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]"