Skip to content

Commit b963fac

Browse files
simeonschaubKristofferC
authored andcommitted
fix printing of LineNumberNode in block within ref (#34504)
(cherry picked from commit 0234e00)
1 parent 5eaa8d6 commit b963fac

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

base/show.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,13 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int, quote_level::In
15801580
print(io, '(')
15811581
ind = indent + indent_width
15821582
for i = 1:length(ex.args)
1583-
i > 1 && print(io, ";\n", ' '^ind)
1583+
if i > 1
1584+
# if there was only a comment before the first semicolon, the expression would get parsed as a NamedTuple
1585+
if !(i == 2 && ex.args[1] isa LineNumberNode)
1586+
print(io, ';')
1587+
end
1588+
print(io, "\n", ' '^ind)
1589+
end
15841590
show_unquoted(io, ex.args[i], ind, -1, quote_level)
15851591
end
15861592
if length(ex.args) < 2

test/show.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,3 +1993,4 @@ end
19931993
@test repr(Base.remove_linenums!(:(a[begin, end, let x=1; (x+1;); end]))) ==
19941994
":(a[begin, end, let x = 1\n begin\n x + 1\n end\n end])"
19951995
@test_repr "a[(bla;)]"
1996+
@weak_test_repr "a[x -> f(x)]"

0 commit comments

Comments
 (0)