File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,10 @@ function is_closing_token(ps::ParseState, k)
220220 (k == K " end" && ! ps. end_symbol)
221221end
222222
223+ function is_block_continuation_keyword (ps:: ParseState , k)
224+ is_block_continuation_keyword (k) && ! (ps. end_symbol && k == K " end" )
225+ end
226+
223227function is_closer_or_newline (ps:: ParseState , k)
224228 is_closing_token (ps,k) || k == K " NewlineWs"
225229end
@@ -658,7 +662,7 @@ function parse_cond(ps::ParseState)
658662
659663 # FIXME : This is a very specific case. Error recovery should be handled more
660664 # generally elsewhere.
661- if is_block_continuation_keyword (kind (t))
665+ if is_block_continuation_keyword (ps, kind (t))
662666 # a "continuaton keyword" is likely to belong to the surrounding code, so
663667 # we abort early
664668
@@ -669,6 +673,8 @@ function parse_cond(ps::ParseState)
669673 bump_invisible (ps, K " error" , TRIVIA_FLAG, error= " unexpected `$(kind (t)) `" )
670674 emit (ps, mark, K " if" )
671675 return
676+ else
677+ # A[x ? y : end] ==> (ref A (? x y end))
672678 end
673679 parse_eq_star (ps)
674680 emit (ps, mark, K " ?" )
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ tests = [
6666 " a ? b: c" => " (? a b (error-t) c)"
6767 " a ? b :c" => " (? a b (error-t) c)"
6868 " a ? b c" => " (? a b (error-t) c)"
69+ " A[x ? y : end]" => " (ref A (? x y end))"
6970 ],
7071 JuliaSyntax. parse_arrow => [
7172 " x → y" => " (call-i x → y)"
You can’t perform that action at this time.
0 commit comments