Skip to content

Commit fd55088

Browse files
authored
add "some warnings detected" to ParseError printing when all problems are warnings (#423)
* try to make warnings clearer * Apply suggestions from code review * Update test/hooks.jl
1 parent 835a527 commit fd55088

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/parser_api.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ function ParseError(stream::ParseStream; incomplete_tag=:none, kws...)
1616
end
1717

1818
function Base.showerror(io::IO, err::ParseError)
19-
println(io, "ParseError:")
2019
# Only show the first parse error for now - later errors are often
2120
# misleading due to the way recovery works
2221
i = findfirst(is_error, err.diagnostics)
2322
if isnothing(i)
2423
i = lastindex(err.diagnostics)
24+
level_info = " some warnings detected:"
25+
else
26+
level_info = ""
2527
end
28+
println(io, "ParseError:", level_info)
2629
show_diagnostics(io, err.diagnostics[1:i], err.source)
2730
end
2831

test/parser_api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ end
163163
catch exc
164164
@test exc isa JuliaSyntax.ParseError
165165
@test sprint(showerror, exc) == """
166-
ParseError:
166+
ParseError: some warnings detected:
167167
# Warning @ somefile.jl:1:2
168168
@(a)
169169
#└─┘ ── parenthesizing macro names is unnecessary"""

0 commit comments

Comments
 (0)