Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #15763, disallow newline immediately after if #15813

Merged
merged 1 commit into from
Apr 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Language changes
* Simple 2-argument comparisons like `A < B` are parsed as calls intead of using the
`:comparison` expression type.

* The `if` keyword cannot be followed immediately by a line break ([#15763]).

Command-line option changes
---------------------------

Expand Down Expand Up @@ -181,3 +183,4 @@ Deprecated or removed
[#15258]: https://github.com/JuliaLang/julia/issues/15258
[#15550]: https://github.com/JuliaLang/julia/issues/15550
[#15609]: https://github.com/JuliaLang/julia/issues/15609
[#15763]: https://github.com/JuliaLang/julia/issues/15763
4 changes: 4 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,10 @@
,body)))

((if)
(if (newline? (peek-token s))
(syntax-deprecation s "if with line break before condition" "")
#;(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
5 changes: 5 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,8 @@ test_parseerror("0x1.0p", "invalid numeric constant \"0x1.0\"")
@test expand(Base.parse_input_line("""
try = "No"
""")) == Expr(:error, "unexpected \"=\"")

# issue #15763
# TODO enable post-0.5
#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")