Skip to content

Commit

Permalink
Improve error message for closing tokens in parse_atom (#261)
Browse files Browse the repository at this point in the history
Fixes #114
  • Loading branch information
c42f committed Apr 29, 2023
1 parent 96c9440 commit 7445401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3557,7 +3557,7 @@ function parse_atom(ps::ParseState, check_identifiers=true)
# ) ==> error
msg = leading_kind == K"EndMarker" ?
"premature end of input" :
"unexpected closing token"
"unexpected `$(untokenize(leading_kind))`"
bump_invisible(ps, K"error", error=msg)
else
bump(ps, error="invalid syntax atom")
Expand Down
3 changes: 3 additions & 0 deletions test/diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ end
# TODO: better range
@test diagnostic("@A.\$x a") ==
Diagnostic(6, 5, :error, "invalid macro name")

@test diagnostic("a, , b") ==
Diagnostic(4, 3, :error, "unexpected `,`")
end

@testset "parser warnings" begin
Expand Down

0 comments on commit 7445401

Please sign in to comment.