Skip to content

Commit d7e4584

Browse files
committed
fix JuliaLang#28576, parsing ? at end of input in conditional expression
1 parent 04f4884 commit d7e4584

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/julia-parser.scm

+2-2
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@
779779
(begin (if (not (ts:space? s))
780780
(error "space required before \"?\" operator"))
781781
(take-token s) ; take the ?
782-
(let ((t (with-whitespace-newline (without-range-colon (peek-token s)))))
782+
(let ((t (with-whitespace-newline (without-range-colon (require-token s)))))
783783
(if (not (ts:space? s))
784784
(error "space required after \"?\" operator")))
785785
(let ((then (without-range-colon (parse-eq* s))))
@@ -788,7 +788,7 @@
788788
(if (not (ts:space? s))
789789
(error "space required before colon in \"?\" expression"))
790790
(take-token s) ; take the :
791-
(let ((t (with-whitespace-newline (peek-token s))))
791+
(let ((t (with-whitespace-newline (require-token s))))
792792
(if (not (ts:space? s))
793793
(error "space required after colon in \"?\" expression")))
794794
(list 'if ex then (parse-eq* s)))))

test/syntax.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1642,3 +1642,7 @@ end
16421642
for ex in [:([x=1]), :(T{x=1})]
16431643
@test Meta.lower(@__MODULE__, ex) == Expr(:error, string("misplaced assignment statement in \"", ex, "\""))
16441644
end
1645+
1646+
# issue #28576
1647+
@test Meta.isexpr(Meta.parse("1 == 2 ?"), :incomplete)
1648+
@test Meta.isexpr(Meta.parse("1 == 2 ? 3 :"), :incomplete)

0 commit comments

Comments
 (0)