Skip to content

Commit

Permalink
deprecate catch <expression>. addresses #19987
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 28, 2017
1 parent ff706aa commit f19c38f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Language changes
warning, so that this syntax can be disallowed or given a new meaning in a
future version ([#5148]).

* Placing an expression after `catch`, as in `catch f(x)`, is deprecated.
Use `catch; f(x)` instead ([#19987]).

* In `for i = ...`, if a local variable `i` already existed it would be overwritten
during the loop. This behavior is deprecated, and in the future `for` loop variables
will always be new variables local to the loop ([#22314]).
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function mirror_callback(remote::Ptr{Ptr{Void}}, repo_ptr::Ptr{Void},
config = GitConfig(GitRepo(repo_ptr,false))
name_str = unsafe_string(name)
err= try set!(config, "remote.$name_str.mirror", true)
catch -1
catch; -1
finally close(config)
end
err != 0 && return Cint(err)
Expand Down
7 changes: 6 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,12 @@
(var (if nl #f (parse-eq* s)))
(var? (and (not nl) (or (and (symbol? var) (not (eq? var 'false))
(not (eq? var 'true)))
(and (length= var 2) (eq? (car var) '$)))))
(and (length= var 2) (eq? (car var) '$))
(and (or (number? var) (large-number? var) (string? var)
(eq? var 'false) (eq? var 'true) (char? var)
(syntax-deprecation s (string "catch " (deparse var) "")
(string "catch; " (deparse var) "")))
#f))))
(catch-block (if (eq? (require-token s) 'finally)
`(block ,(line-number-node s))
(parse-block s))))
Expand Down
2 changes: 1 addition & 1 deletion test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ end

# issue #16686
@test parse("try x
catch test()
catch; test()
y
end") == Expr(:try,
Expr(:block,
Expand Down

0 comments on commit f19c38f

Please sign in to comment.