From e7ec975ad3593e258f555aae56e77183adfda75f Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Fri, 24 Jan 2020 19:16:28 +0100 Subject: [PATCH] fix printing of LineNumberNode in block within ref --- base/show.jl | 8 +++++++- test/show.jl | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/base/show.jl b/base/show.jl index 3ce4ea7c51da86..ccdcdcc2d1c47d 100644 --- a/base/show.jl +++ b/base/show.jl @@ -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 diff --git a/test/show.jl b/test/show.jl index d89cbe7060b15d..f92fa075e13d84 100644 --- a/test/show.jl +++ b/test/show.jl @@ -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;)]" +@weak_test_repr "a[x -> f(x)]"