Skip to content

Commit

Permalink
fix #15763, disallow newline immediately after if
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 8, 2016
1 parent b76bc89 commit 7e38439
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,9 @@
,body)))

((if)
(if (newline? (peek-token s))
(error (string "missing condition in \"if\" at " current-filename
":" (- (input-port-line (ts:port s)) 1))))
(let* ((test (parse-cond s))
(then (if (memq (require-token s) '(else elseif))
'(block)
Expand Down
4 changes: 4 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,7 @@ test_parseerror("0x1.0p", "invalid numeric constant \"0x1.0\"")
@test expand(Base.parse_input_line("""
try = "No"
""")) == Expr(:error, "unexpected \"=\"")

# issue #15763
test_parseerror("if\nfalse\nend", "missing condition in \"if\" at none:1")
test_parseerror("if false\nelseif\nend", "missing condition in \"elseif\" at none:2")

0 comments on commit 7e38439

Please sign in to comment.