Skip to content

Commit

Permalink
fix printing of LineNumberNode in block within ref
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonschaub committed Jan 24, 2020
1 parent b8c6386 commit 20d6b82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,13 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
print(io, '(')
ind = indent + indent_width
for i = 1:length(ex.args)
i > 1 && print(io, ";\n", ' '^ind)
if i > 1
# if there was only a comment before the first semicolon, the expression would get parsed as a NamedTuple
if !(i == 2 && ex.args[1] isa LineNumberNode)
print(io, ';')
end
print(io, "\n", ' '^ind)
end
show_unquoted(io, ex.args[i], ind, -1, quote_level)
end
if length(ex.args) < 2
Expand Down
1 change: 1 addition & 0 deletions test/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1993,3 +1993,4 @@ end
@test repr(Base.remove_linenums!(:(a[begin, end, let x=1; (x+1;); end]))) ==
":(a[begin, end, let x = 1\n begin\n x + 1\n end\n end])"
@test_repr "a[(bla;)]"
@test_repr "a[x -> f(x)]"

0 comments on commit 20d6b82

Please sign in to comment.