Skip to content

Commit 7445401

Browse files
authored
Improve error message for closing tokens in parse_atom (#261)
Fixes #114
1 parent 96c9440 commit 7445401

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/parser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ function parse_atom(ps::ParseState, check_identifiers=true)
35573557
# ) ==> error
35583558
msg = leading_kind == K"EndMarker" ?
35593559
"premature end of input" :
3560-
"unexpected closing token"
3560+
"unexpected `$(untokenize(leading_kind))`"
35613561
bump_invisible(ps, K"error", error=msg)
35623562
else
35633563
bump(ps, error="invalid syntax atom")

test/diagnostics.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ end
2424
# TODO: better range
2525
@test diagnostic("@A.\$x a") ==
2626
Diagnostic(6, 5, :error, "invalid macro name")
27+
28+
@test diagnostic("a, , b") ==
29+
Diagnostic(4, 3, :error, "unexpected `,`")
2730
end
2831

2932
@testset "parser warnings" begin

0 commit comments

Comments
 (0)