Skip to content

Commit

Permalink
expand deprecation warnings to cover all uses of x.(i) for getfield(x…
Browse files Browse the repository at this point in the history
…, i); this PR should no longer be a breaking change
  • Loading branch information
stevengj committed May 6, 2016
1 parent e847332 commit fe53f21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 0 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ Breaking changes
instead, a call that cannot be resolved to a single method results
in a `MethodError`. ([#6190])

* The syntax `x.(i::Integer)` for `getfield(x,i)` now means `broadcast(x,i)`.
[`x.(s::Symbol)` still works for `getfield(x,s)`, and `x.(f) = v` works for `setfield!(x, f, v)`, but these are deprecated.]
Use `getfield` or `setfield!` instead ([#15032]).

* `pmap` keyword arguments `err_retry=true` and `err_stop=false` are deprecated.
`pmap` no longer retries or returns `Exception` objects in the result collection.
`pmap(retry(f), c)` or `pmap(@catch(f), c)` can be used instead.
Expand Down
24 changes: 12 additions & 12 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1093,22 +1093,22 @@ end
#15995
@deprecate symbol Symbol

#15032: Expressions like Base.(:+) now call broadcast. Since there is unlikely
# to be any legitimate reason to broadcast to a Module (not iterable!),
# it should be safe to catch this with a deprecation method.
# Note: this deprecation does not handle method definitions Base.(:+)(...) = ...,
# which are handled by the deprecate-dotparen function in julia-syntax.scm
# More generally, expressions like x.(sym) for any Symbol turn into broadcast
# but should really be getfield, and since you can't broadcast to a symbol
# using a deprecated broadcast method should be safe. [Unfortunately,
# we can't catch x.(i::Int) in the same way, because broadcasting to an
# integer is a valid use of broadcast Most such usages will simply
# give an error, since x is probably not callable if getfield was intended.]
#15032: Expressions like Base.(:+) now call broadcast. Since calls
# to broadcast(x, ::Symbol) are unheard of, and broadcast(x, ::Integer)
# are unlikely, we can treat these as deprecated getfield calls.
function broadcast(x::Any, i::Union{Integer,Symbol})
depwarn("x.(i) is deprecated; use getfield(x, i) instead.", :broadcast)
getfield(x, i)
end
# clearer to be more explicit in the warning for the Module case
function broadcast(m::Module, s::Symbol)
depwarn("$m.(:$s) is deprecated; use $m.:$s or getfield($m, :$s) instead.", :broadcast)
getfield(m, s)
end
@deprecate broadcast(x::Any, s::Symbol) getfield(x, s)
# expressions like f.(3) should still call broadcast for f::Function,
# and in general broadcast should work for scalar arguments, while
# getfield is certainly not intended for the case of f::Function.
broadcast(f::Function, i::Integer) = invoke(broadcast, (Function, Number), f, i)

#16167
macro ccallable(def)
Expand Down

0 comments on commit fe53f21

Please sign in to comment.