From a935100e75f604b664ec6a7c64a6cffb94909d2c 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 (cherry picked from commit e8d2b02fb9876107fa1c42593f1bcdab54a231b1) ref #15527 --- 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 96cd56cbaa2ed..5c1f78bc4b263 100644 --- a/base/show.jl +++ b/base/show.jl @@ -522,7 +522,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 = " " @@ -531,7 +531,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 38ff1a1b5118d..17d0812476523 100644 --- a/test/show.jl +++ b/test/show.jl @@ -354,3 +354,9 @@ macro strquote(ex) end str_ex2a, str_ex2b = @strquote(begin x end), string(quote x end) @test str_ex2a == str_ex2b + +# Issue #15525, printing of vcat +@test sprint(show, :([a;])) == ":([a;])" +@test sprint(show, :([a;b])) == ":([a;b])" +@test_repr "[a;]" +@test_repr "[a;b]"