Skip to content

Commit

Permalink
fix #28576, parsing ? at end of input in conditional expression
Browse files Browse the repository at this point in the history
(cherry picked from commit d7e4584)
  • Loading branch information
JeffBezanson authored and KristofferC committed Aug 19, 2018
1 parent 4dfbcef commit abfa53d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@
(begin (if (not (ts:space? s))
(error "space required before \"?\" operator"))
(take-token s) ; take the ?
(let ((t (with-whitespace-newline (without-range-colon (peek-token s)))))
(let ((t (with-whitespace-newline (without-range-colon (require-token s)))))
(if (not (ts:space? s))
(error "space required after \"?\" operator")))
(let ((then (without-range-colon (parse-eq* s))))
Expand All @@ -788,7 +788,7 @@
(if (not (ts:space? s))
(error "space required before colon in \"?\" expression"))
(take-token s) ; take the :
(let ((t (with-whitespace-newline (peek-token s))))
(let ((t (with-whitespace-newline (require-token s))))
(if (not (ts:space? s))
(error "space required after colon in \"?\" expression")))
(list 'if ex then (parse-eq* s)))))
Expand Down
4 changes: 4 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1642,3 +1642,7 @@ end
for ex in [:([x=1]), :(T{x=1})]
@test Meta.lower(@__MODULE__, ex) == Expr(:error, string("misplaced assignment statement in \"", ex, "\""))
end

# issue #28576
@test Meta.isexpr(Meta.parse("1 == 2 ?"), :incomplete)
@test Meta.isexpr(Meta.parse("1 == 2 ? 3 :"), :incomplete)

0 comments on commit abfa53d

Please sign in to comment.