Skip to content

Commit d00a04a

Browse files
committed
Minor fix to test case comment + unify recovery for parsing :
1 parent 3e6c07f commit d00a04a

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/parser.jl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,6 @@ function parse_atom(ps::ParseState, check_identifiers=true)
32443244
if leading_kind == K":"
32453245
# symbol/expression quote
32463246
# :foo ==> (quote foo)
3247-
# : foo ==> (quote (error-t) foo)
32483247
t = peek_token(ps, 2)
32493248
k = kind(t)
32503249
if is_closing_token(ps, k) && (!is_keyword(k) || preceding_whitespace(t))
@@ -3256,19 +3255,12 @@ function parse_atom(ps::ParseState, check_identifiers=true)
32563255
end
32573256
bump(ps, TRIVIA_FLAG) # K":"
32583257
if preceding_whitespace(t)
3259-
# : a ==> (quote (error-t) a))
3260-
# ===
3261-
# :
3262-
# a
3263-
# ==> (quote (error))
3264-
bump_trivia(ps, TRIVIA_FLAG,
3258+
# : foo ==> (quote (error-t) foo)
3259+
# :\nfoo ==> (quote (error-t) foo)
3260+
bump_trivia(ps, TRIVIA_FLAG, skip_newlines=true,
32653261
error="whitespace not allowed after `:` used for quoting")
32663262
# Heuristic recovery
3267-
if kind(t) == K"NewlineWs"
3268-
bump_invisible(ps, K"error")
3269-
else
3270-
bump(ps)
3271-
end
3263+
bump(ps)
32723264
else
32733265
# Being inside quote makes keywords into identifiers at at the
32743266
# first level of nesting

test/parser.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,12 @@ tests = [
568568
],
569569
JuliaSyntax.parse_atom => [
570570
":foo" => "(quote foo)"
571-
": foo" => "(quote (error-t) foo)"
572571
# Literal colons
573572
":)" => ":"
574573
": end" => ":"
574+
# Whitespace after quoting colon
575+
": foo" => "(quote (error-t) foo)"
576+
":\nfoo" => "(quote (error-t) foo)"
575577
# plain equals
576578
"=" => "(error =)"
577579
# Identifiers

0 commit comments

Comments
 (0)