Skip to content

Commit

Permalink
fix regression in expression printing (ref #5879)
Browse files Browse the repository at this point in the history
fix #5898, showing 1-arg form of kw expr (used internally)

add prettyprinting of string interpolation
  without this, test-show fails on my fix to #5879, which helps explain
  why things were that way
  • Loading branch information
JeffBezanson committed Feb 22, 2014
1 parent 0b2d867 commit cd5cd76
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,20 +491,33 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int)
show(io, args[1])
elseif is(head, :null)
print(io, "nothing")
elseif is(head, :kw)
elseif is(head, :kw) && length(args)==2
show_unquoted(io, args[1], indent+indent_width)
print(io, '=')
show_unquoted(io, args[2], indent+indent_width)
elseif is(head, :string)
a = map(args) do x
if !isa(x,String)
if isa(x,Symbol) && !(x in quoted_syms)
string("\$", x)
else
string("\$(", sprint(show_unquoted,x), ")")
end
else
sprint(print_escaped, x, "\"\$")
end
end
print(io, '"', a..., '"')

# print anything else as "Expr(head, args...)"
else
print(io, "Expr(")
show_unquoted(io, ex.head, indent)
print(io, "\$(Expr(")
show(io, ex.head)
for arg in args
print(io, ", ")
show_unquoted(io, arg, indent)
show(io, arg)
end
print(io, ")")
print(io, "))")
end

show_expr_type(io, ex.typ)
Expand Down

0 comments on commit cd5cd76

Please sign in to comment.