Skip to content

Commit

Permalink
fix a few more deprecation-related items
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 7, 2018
1 parent 60cf688 commit 6575e12
Show file tree
Hide file tree
Showing 24 changed files with 59 additions and 118 deletions.
3 changes: 3 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,9 @@ julia> map(+, [1, 2, 3], [10, 20, 30])
"""
map(f, A) = collect(Generator(f,A))

map(f, ::AbstractDict) = error("map is not defined on dictionaries")
map(f, ::AbstractSet) = error("map is not defined on sets")

## 2 argument
function map!(f::F, dest::AbstractArray, A::AbstractArray, B::AbstractArray) where F
for (i, j, k) in zip(eachindex(dest), eachindex(A), eachindex(B))
Expand Down
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ Base.RefValue{String}("hello")
```
"""
broadcastable(x::Union{Symbol,AbstractString,Function,UndefInitializer,Nothing,RoundingMode,Missing,Val}) = Ref(x)
broadcastable(x::Ptr) = Ref{Ptr}(x) # Cannot use Ref(::Ptr) until ambiguous deprecation goes through
broadcastable(x::Ptr) = Ref(x)
broadcastable(::Type{T}) where {T} = Ref{Type{T}}(T)
broadcastable(x::Union{AbstractArray,Number,Ref,Tuple,Broadcasted}) = x
# Default to collecting iterables — which will error for non-iterables
Expand Down
1 change: 0 additions & 1 deletion base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ end
baremodule MainInclude
include(fname::AbstractString) = Main.Base.include(Main, fname)
eval(x) = Core.eval(Main, x)
Main.Base.@deprecate eval(m, x) Core.eval(m, x)
end

"""
Expand Down
6 changes: 0 additions & 6 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

const CoreNumType = Union{Int32, Int64, Float32, Float64}

const DEPRECATED_SYM = Symbol("deprecated.jl")

const _REF_NAME = Ref.body.name

#########
Expand Down Expand Up @@ -199,10 +197,6 @@ function abstract_call_method_with_const_args(@nospecialize(f), argtypes::Vector
end

function abstract_call_method(method::Method, @nospecialize(sig), sparams::SimpleVector, sv::InferenceState)
# TODO: remove with 0.7 deprecations
if method.file === DEPRECATED_SYM && method.sig == (Tuple{Type{T},Any} where T)
return Any, false, nothing
end
if method.name === :depwarn && isdefined(Main, :Base) && method.module === Main.Base
return Any, false, nothing
end
Expand Down
1 change: 0 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ function evalfile(path::AbstractString, args::Vector{String}=String[])
Expr(:toplevel,
:(const ARGS = $args),
:(eval(x) = $(Expr(:core, :eval))(__anon__, x)),
:(@deprecate eval(m, x) Core.eval(m, x)),
:(include(x) = $(Expr(:top, :include))(__anon__, x)),
:(include($path))))
end
Expand Down
9 changes: 3 additions & 6 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ function task_local_storage(body::Function, key, val)
end

# NOTE: you can only wait for scheduled tasks
# TODO: rename to wait for 1.0
function _wait(t::Task)
function wait(t::Task)
if !istaskdone(t)
if t.donenotify === nothing
t.donenotify = Condition()
Expand All @@ -193,16 +192,14 @@ function _wait(t::Task)
end
end

_wait(not_a_task) = wait(not_a_task)

"""
fetch(t::Task)
Wait for a Task to finish, then return its result value. If the task fails with an
exception, the exception is propagated (re-thrown in the task that called fetch).
"""
function fetch(t::Task)
_wait(t)
wait(t)
task_result(t)
end

Expand All @@ -213,7 +210,7 @@ function sync_end(refs)
c_ex = CompositeException()
for r in refs
try
_wait(r)
wait(r)
catch ex
if !isa(r, Task) || (isa(r, Task) && !istaskfailed(r))
rethrow(ex)
Expand Down
17 changes: 6 additions & 11 deletions src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -378,25 +378,20 @@
(symbol (string.sub str 1 (length str)))))

; convert '.xx to 'xx, and (|.| _ '.xx) to (|.| _ 'xx), and otherwise return #f
(define (maybe-undotop e)
;; raise an error for using .op as a function name
(define (check-dotop e)
(if (symbol? e)
(let ((str (string e)))
(if (and (eqv? (string.char str 0) #\.)
(not (eq? e '|.|))
(not (eqv? (string.char str 1) #\.)))
(symbol (string.sub str 1 (length str)))
#f))
(error (string "invalid function name \"" e "\""))))
(if (pair? e)
(if (eq? (car e) '|.|)
(let ((op (maybe-undotop (caddr e))))
(if op
(list '|.| (cadr e) op)
#f))
(check-dotop (caddr e))
(if (quoted? e)
(let ((op (maybe-undotop (cadr e))))
(if op (list (car e) op) #f))
#f))
#f)))
(check-dotop (cadr e))))))
e)

(define (vararg? x) (and (pair? x) (eq? (car x) '...)))
(define (varargexpr? x) (and
Expand Down
12 changes: 6 additions & 6 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,12 @@
(else
(list (=-to-kw e)))))

(define invalid-identifier? (Set (list* '.... '? '|.'| syntactic-operators)))

(define-macro (check-identifier ex)
`(if (invalid-identifier? ,ex)
(error (string "invalid identifier name \"" ,ex "\""))))

(define (parse-paren s (checked #t)) (car (parse-paren- s checked)))

;; return (expr . arglist) where arglist is #t iff this isn't just a parenthesized expr
Expand Down Expand Up @@ -2220,12 +2226,6 @@
;; process escape sequences using lisp read
(read (open-input-string (string #\" s #\"))))))

(define invalid-identifier? (Set (list* '.... '? '|.'| syntactic-operators)))

(define-macro (check-identifier ex)
`(if (invalid-identifier? ,ex)
(error (string "invalid identifier name \"" ,ex "\""))))

;; parse numbers, identifiers, parenthesized expressions, lists, vectors, etc.
(define (parse-atom s (checked #t))
(let ((t (require-token s)))
Expand Down
39 changes: 5 additions & 34 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,6 @@
(pair? (caddr e)) (memq (car (caddr e)) '(quote inert))
(symbol? (cadr (caddr e))))))

;; e.g. Base.(:+) is deprecated in favor of Base.:+
(define (deprecate-dotparen e)
(if (and (length= e 3) (eq? (car e) '|.|)
(or (atom? (cadr e)) (sym-ref? (cadr e)))
(length= (caddr e) 2) (eq? (caaddr e) 'tuple)
(pair? (cadr (caddr e))) (memq (caadr (caddr e)) '(quote inert)))
(let* ((s_ (cdadr (caddr e)))
(s (if (symbol? s_) s_
(if (and (length= s_ 1) (symbol? (car s_))) (car s_) #f))))
(if s
(let ((newe (list (car e) (cadr e) (cadr (caddr e))))
(S (deparse `(quote ,s)))) ; #16295
(syntax-deprecation (string (deparse (cadr e)) ".(" S ")")
(string (deparse (cadr e)) "." S) #f)
newe)
e))
e))

;; convert final (... x) to (curly Vararg x)
(define (dots->vararg a)
(if (null? a) a
Expand Down Expand Up @@ -1019,20 +1001,13 @@
((eq? (car name) 'call)
(let* ((head (cadr name))
(argl (cddr name))
(name (deprecate-dotparen head))
(op (let ((op_ (maybe-undotop name))) ; handle .op -> broadcast deprecation
(if op_
(syntax-deprecation (string "function " (deparse name) "(...)")
(string "function Base.broadcast(::typeof(" (deparse op_) "), ...)") #f))
op_))
(name (if op '(|.| Base (inert broadcast)) name))
(name (check-dotop head))
(annotations (map (lambda (a) `(meta ,(cadr a) ,(arg-name (caddr a))))
(filter nospecialize-meta? argl)))
(body (insert-after-meta (caddr e) annotations))
(argl (map (lambda (a)
(if (nospecialize-meta? a) (caddr a) a))
argl))
(argl (if op (cons `(|::| (call (core Typeof) ,op)) argl) argl))
(raw-typevars (or where '()))
(sparams (map analyze-typevar raw-typevars))
(adj-decl (lambda (n) (if (and (decl? n) (length= n 2))
Expand Down Expand Up @@ -1893,15 +1868,11 @@
((|.|)
;; a.b =
(let* ((a (cadr lhs))
(b_ (caddr lhs))
(b (if (and (length= b_ 2) (eq? (car b_) 'tuple))
(begin
(syntax-deprecation
(string (deparse a) ".(" (deparse (cadr b_)) ") = ...")
(string "setfield!(" (deparse a) ", " (deparse (cadr b_)) ", ...)") #f)
(cadr b_))
b_))
(b (caddr lhs))
(rhs (caddr e)))
(if (and (length= b 2) (eq? (car b) 'tuple))
(error (string "invalid syntax \""
(string (deparse a) ".(" (deparse (cadr b)) ") = ...") "\"")))
(let ((aa (if (symbol-like? a) a (make-ssavalue)))
(bb (if (or (atom? b) (symbol-like? b) (and (pair? b) (quoted? b)))
b (make-ssavalue)))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function addprocs_locked(manager::ClusterManager; kwargs...)
end
end

Base._wait(t_launch) # catches any thrown errors from the launch task
Base.wait(t_launch) # catches any thrown errors from the launch task

# Since all worker-to-worker setups may not have completed by the time this
# function returns to the caller, send the complete list to all workers.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Distributed/src/process_messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function handle_msg(msg::JoinPGRPMsg, header, r_stream, w_stream, version)
end
end

for wt in wait_tasks; Base._wait(wt); end
for wt in wait_tasks; Base.wait(wt); end

send_connection_hdr(controller, false)
send_msg_now(controller, MsgHeader(RRID(0,0), header.notify_oid), JoinCompleteMsg(Sys.CPU_THREADS, getpid()))
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ end # full-test

let t = @task 42
schedule(t, ErrorException(""), error=true)
@test_throws ErrorException Base._wait(t)
@test_throws ErrorException Base.wait(t)
end

# issue #8207
Expand Down Expand Up @@ -1049,7 +1049,7 @@ for i in 1:5
p = addprocs_with_testenv(1)[1]
np = nprocs()
@spawnat p sleep(5)
Base._wait(rmprocs(p; waitfor=0))
Base.wait(rmprocs(p; waitfor=0))
for pid in procs()
@test pid == remotecall_fetch(myid, pid)
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/FileWatching/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ for (i, intvl) in enumerate(intvls)
end
notify(ready_c, all=true)
for idx in 1:n
Base._wait(t[idx])
Base.wait(t[idx])
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions stdlib/LinearAlgebra/src/special.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ _small_enough(A::Bidiagonal) = size(A, 1) <= 1
_small_enough(A::Tridiagonal) = size(A, 1) <= 2
_small_enough(A::SymTridiagonal) = size(A, 1) <= 2

# TODO: Add Diagonal to this method when 0.7 deprecations are removed
function fill!(A::Union{Bidiagonal,Tridiagonal,SymTridiagonal}, x)
function fill!(A::Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagonal}, x)
xT = convert(eltype(A), x)
(iszero(xT) || _small_enough(A)) && return fillstored!(A, xT)
throw(ArgumentError("array of type $(typeof(A)) and size $(size(A)) can
Expand Down
6 changes: 1 addition & 5 deletions stdlib/Pkg/ext/TOML/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using TOML
import TOML: linecol, whitespace, comment, newline, expect, lookup, Parser, parse

if Base.isdeprecated(Base, :Test)
using Test
else
using Base.Test
end
using Test

macro testval(s, v)
f = "foo = $s"
Expand Down
14 changes: 7 additions & 7 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function fake_repl(@nospecialize(f); options::REPL.Options=REPL.Options(confirm_
end
@test read(err.out, String) == ""
#display(read(output.out, String))
Base._wait(t)
Base.wait(t)
close(hard_kill)
nothing
end
Expand Down Expand Up @@ -300,7 +300,7 @@ fake_repl() do stdin_write, stdout_read, repl

# Close REPL ^D
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)

nothing
end
Expand Down Expand Up @@ -671,7 +671,7 @@ fake_repl() do stdin_write, stdout_read, repl

# Close repl
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)
end

# Simple non-standard REPL tests
Expand Down Expand Up @@ -711,7 +711,7 @@ fake_repl() do stdin_write, stdout_read, repl
@test wait(c) == "a"
# Close REPL ^D
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)
end

ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 1)
Expand Down Expand Up @@ -882,7 +882,7 @@ for keys = [altkeys, merge(altkeys...)],

# Close REPL ^D
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)

# Close the history file
# (otherwise trying to delete it fails on Windows)
Expand Down Expand Up @@ -938,7 +938,7 @@ fake_repl() do stdin_write, stdout_read, repl

# Close REPL ^D
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)
end

# Docs.helpmode tests: we test whether the correct expressions are being generated here,
Expand Down Expand Up @@ -975,5 +975,5 @@ fake_repl() do stdin_write, stdout_read, repl
readline(stdout_read)
@test readline(stdout_read) == "\e[0m:((Base.Math.float)(_1))"
write(stdin_write, '\x04')
Base._wait(repltask)
Base.wait(repltask)
end
4 changes: 2 additions & 2 deletions stdlib/Serialization/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ Core.eval(Main, main_ex)
create_serialization_stream() do s # user-defined type array
f = () -> begin task_local_storage(:v, 2); return 1+1 end
t = Task(f)
Base._wait(schedule(t))
Base.wait(schedule(t))
serialize(s, t)
seek(s, 0)
r = deserialize(s)
Expand All @@ -349,7 +349,7 @@ end
struct MyErrorTypeTest <: Exception end
create_serialization_stream() do s # user-defined type array
t = Task(()->throw(MyErrorTypeTest()))
@test_throws MyErrorTypeTest Base._wait(schedule(t))
@test_throws MyErrorTypeTest Base.wait(schedule(t))
serialize(s, t)
seek(s, 0)
r = deserialize(s)
Expand Down
Loading

0 comments on commit 6575e12

Please sign in to comment.