Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "some warnings detected" to ParseError printing when all problems are warnings #423

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/parser_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ function ParseError(stream::ParseStream; incomplete_tag=:none, kws...)
end

function Base.showerror(io::IO, err::ParseError)
println(io, "ParseError:")
# Only show the first parse error for now - later errors are often
# misleading due to the way recovery works
i = findfirst(is_error, err.diagnostics)
if isnothing(i)
i = lastindex(err.diagnostics)
level_info = " some warnings detected:"
else
level_info = ""
end
println(io, "ParseError:", level_info)
show_diagnostics(io, err.diagnostics[1:i], err.source)
end

Expand Down
2 changes: 1 addition & 1 deletion test/parser_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ end
catch exc
@test exc isa JuliaSyntax.ParseError
@test sprint(showerror, exc) == """
ParseError:
ParseError: some warnings detected:
# Warning @ somefile.jl:1:2
@(a)
#└─┘ ── parenthesizing macro names is unnecessary"""
Expand Down
Loading