Skip to content

Commit 62d6226

Browse files
committed
Also handle newline ws
1 parent f9b857e commit 62d6226

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/parser.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ function parse_cond(ps::ParseState)
637637
# a ? b c ==> (if a b (error) c)
638638
bump_invisible(ps, K"error", TRIVIA_FLAG, error="`:` expected in `?` expression")
639639
end
640-
t = peek_token(ps)
640+
t = peek_token(ps; skip_newlines = true)
641641
if !preceding_whitespace(t)
642642
# a ? b :c ==> (if a [ ] [?] [ ] b [ ] [:] (error-t) c)
643643
bump_invisible(ps, K"error", TRIVIA_FLAG, error="space required after `:` in `?` expression")
@@ -648,6 +648,7 @@ function parse_cond(ps::ParseState)
648648

649649
# if true; x ? true elseif true end ==> (if true (block (if x true (error-t) (error-t))) (elseif true (block)))
650650
# if true; x ? true end ==> (if true (block (if x true (error-t) (error-t))))
651+
# if true; x ? true\n end ==> (if true (block (if x true (error-t) (error-t))))
651652
# if true; x ? true : elseif true end ==> (if true (block (if x true (error-t))) (elseif true (block)))
652653
bump_invisible(ps, K"error", TRIVIA_FLAG, error="unexpected `$(kind(t))`")
653654
emit(ps, mark, K"if")

test/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ tests = [
404404
"if a xx else yy end" => "(if a (block xx) (block yy))"
405405
"if true; x ? true elseif true end" => "(if true (block (if x true (error-t) (error-t))) (elseif true (block)))"
406406
"if true; x ? true end" => "(if true (block (if x true (error-t) (error-t))))"
407+
"if true; x ? true\nend" => "(if true (block (if x true (error-t) (error-t))))"
407408
"if true; x ? true : elseif true end" => "(if true (block (if x true (error-t))) (elseif true (block)))"
408409
],
409410
JuliaSyntax.parse_const_local_global => [

0 commit comments

Comments
 (0)