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
  • Loading branch information
JeffBezanson committed Aug 12, 2018
1 parent 04f4884 commit d7e4584
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)

1 comment on commit d7e4584

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.