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 more invalidations from overloading == #36282

Merged
merged 5 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix more == invalidations
  • Loading branch information
timholy committed Jun 14, 2020
commit 8094867569bbdf422e434058e8a607933db2dff8
18 changes: 14 additions & 4 deletions base/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,27 @@ const exprresolve_cond_dict = Dict{Symbol,Function}(:(==) => ==,
:(<) => <, :(>) => >, :(<=) => <=, :(>=) => >=)

function exprresolve_arith(ex::Expr)
if ex.head === :call && haskey(exprresolve_arith_dict, ex.args[1]) && all([isa(ex.args[i], Number) for i = 2:length(ex.args)])
return true, exprresolve_arith_dict[ex.args[1]](ex.args[2:end]...)
if ex.head === :call
callee = ex.args[1]
if isa(callee, Symbol)
if haskey(exprresolve_arith_dict, callee) && all([isa(ex.args[i], Number) for i = 2:length(ex.args)])
timholy marked this conversation as resolved.
Show resolved Hide resolved
return true, exprresolve_arith_dict[callee](ex.args[2:end]...)
end
end
end
false, 0
end
exprresolve_arith(arg) = false, 0

exprresolve_conditional(b::Bool) = true, b
function exprresolve_conditional(ex::Expr)
if ex.head === :call && ex.args[1] ∈ keys(exprresolve_cond_dict) && isa(ex.args[2], Number) && isa(ex.args[3], Number)
return true, exprresolve_cond_dict[ex.args[1]](ex.args[2], ex.args[3])
if ex.head === :call
callee = ex.args[1]
if isa(callee, Symbol)
if callee ∈ keys(exprresolve_cond_dict) && isa(ex.args[2], Number) && isa(ex.args[3], Number)
return true, exprresolve_cond_dict[callee](ex.args[2], ex.args[3])
end
end
end
false, false
end
Expand Down
2 changes: 1 addition & 1 deletion base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function doc!(__module__::Module, b::Binding, str::DocStr, @nospecialize sig = U
# We allow for docstrings to be updated, but print a warning since it is possible
# that over-writing a docstring *may* have been accidental. The warning
# is suppressed for symbols in Main, for interactive use (#23011).
__module__ == Main || @warn "Replacing docs for `$b :: $sig` in module `$(__module__)`"
__module__ === Main || @warn "Replacing docs for `$b :: $sig` in module `$(__module__)`"
else
# The ordering of docstrings for each Binding is defined by the order in which they
# are initially added. Replacing a specific docstring does not change it's ordering.
Expand Down
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
ft = typeof(f)
lines = []
# These functions are special cased to only show if first argument is matched.
special = f in [convert, getindex, setindex!]
special = f === convert || f === getindex || f === setindex!
funcs = Any[(f, arg_types_param)]

# An incorrect call method produces a MethodError for convert.
Expand Down
2 changes: 1 addition & 1 deletion base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function display(@nospecialize x)
try
return display(displays[i], x)
catch e
isa(e, MethodError) && e.f in (display, show) ||
isa(e, MethodError) && (e.f === display || e.f === show) ||
rethrow()
end
end
Expand Down
22 changes: 11 additions & 11 deletions stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function set_worker_state(w, state)
end

function check_worker_state(w::Worker)
if w.state == W_CREATED
if w.state === W_CREATED
if !isclusterlazy()
if PGRP.topology === :all_to_all
# Since higher pids connect with lower pids, the remote worker
Expand Down Expand Up @@ -185,13 +185,13 @@ function exec_conn_func(w::Worker)
end

function wait_for_conn(w)
if w.state == W_CREATED
if w.state === W_CREATED
timeout = worker_timeout() - (time() - w.ct_time)
timeout <= 0 && error("peer $(w.id) has not connected to $(myid())")

@async (sleep(timeout); notify(w.c_state; all=true))
wait(w.c_state)
w.state == W_CREATED && error("peer $(w.id) didn't connect to $(myid()) within $timeout seconds")
w.state === W_CREATED && error("peer $(w.id) didn't connect to $(myid()) within $timeout seconds")
end
nothing
end
Expand Down Expand Up @@ -626,7 +626,7 @@ function create_worker(manager, wconfig)
# require the value of config.connect_at which is set only upon connection completion
for jw in PGRP.workers
if (jw.id != 1) && (jw.id < w.id)
(jw.state == W_CREATED) && wait(jw.c_state)
(jw.state === W_CREATED) && wait(jw.c_state)
push!(join_list, jw)
end
end
Expand All @@ -649,7 +649,7 @@ function create_worker(manager, wconfig)
end

for wl in wlist
(wl.state == W_CREATED) && wait(wl.c_state)
(wl.state === W_CREATED) && wait(wl.c_state)
push!(join_list, wl)
end
end
Expand Down Expand Up @@ -851,7 +851,7 @@ function nprocs()
n = length(PGRP.workers)
# filter out workers in the process of being setup/shutdown.
for jw in PGRP.workers
if !isa(jw, LocalProcess) && (jw.state != W_CONNECTED)
if !isa(jw, LocalProcess) && (jw.state !== W_CONNECTED)
n = n - 1
end
end
Expand Down Expand Up @@ -902,7 +902,7 @@ julia> procs()
function procs()
if myid() == 1 || (PGRP.topology === :all_to_all && !isclusterlazy())
# filter out workers in the process of being setup/shutdown.
return Int[x.id for x in PGRP.workers if isa(x, LocalProcess) || (x.state == W_CONNECTED)]
return Int[x.id for x in PGRP.workers if isa(x, LocalProcess) || (x.state === W_CONNECTED)]
else
return Int[x.id for x in PGRP.workers]
end
Expand All @@ -911,7 +911,7 @@ end
function id_in_procs(id) # faster version of `id in procs()`
if myid() == 1 || (PGRP.topology === :all_to_all && !isclusterlazy())
for x in PGRP.workers
if (x.id::Int) == id && (isa(x, LocalProcess) || (x::Worker).state == W_CONNECTED)
if (x.id::Int) == id && (isa(x, LocalProcess) || (x::Worker).state === W_CONNECTED)
return true
end
end
Expand All @@ -933,7 +933,7 @@ Specifically all workers bound to the same ip-address as `pid` are returned.
"""
function procs(pid::Integer)
if myid() == 1
all_workers = [x for x in PGRP.workers if isa(x, LocalProcess) || (x.state == W_CONNECTED)]
all_workers = [x for x in PGRP.workers if isa(x, LocalProcess) || (x.state === W_CONNECTED)]
if (pid == 1) || (isa(map_pid_wrkr[pid].manager, LocalManager))
Int[x.id for x in filter(w -> (w.id==1) || (isa(w.manager, LocalManager)), all_workers)]
else
Expand Down Expand Up @@ -1040,11 +1040,11 @@ function _rmprocs(pids, waitfor)

start = time_ns()
while (time_ns() - start) < waitfor*1e9
all(w -> w.state == W_TERMINATED, rmprocset) && break
all(w -> w.state === W_TERMINATED, rmprocset) && break
sleep(min(0.1, waitfor - (time_ns() - start)/1e9))
end

unremoved = [wrkr.id for wrkr in filter(w -> w.state != W_TERMINATED, rmprocset)]
unremoved = [wrkr.id for wrkr in filter(w -> w.state !== W_TERMINATED, rmprocset)]
if length(unremoved) > 0
estr = string("rmprocs: pids ", unremoved, " not terminated after ", waitfor, " seconds.")
throw(ErrorException(estr))
Expand Down
6 changes: 3 additions & 3 deletions stdlib/LibGit2/src/LibGit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function fetch(repo::GitRepo; remote::AbstractString="origin",
fo = FetchOptions(callbacks=remote_callbacks)
fetch(rmt, refspecs, msg="from $(url(rmt))", options=fo)
catch err
if isa(err, GitError) && err.code == Error.EAUTH
if isa(err, GitError) && err.code === Error.EAUTH
reject(cred_payload)
else
Base.shred!(cred_payload)
Expand Down Expand Up @@ -345,7 +345,7 @@ function push(repo::GitRepo; remote::AbstractString="origin",
push_opts = PushOptions(callbacks=remote_callbacks)
push(rmt, refspecs, force=force, options=push_opts)
catch err
if isa(err, GitError) && err.code == Error.EAUTH
if isa(err, GitError) && err.code === Error.EAUTH
reject(cred_payload)
else
Base.shred!(cred_payload)
Expand Down Expand Up @@ -579,7 +579,7 @@ function clone(repo_url::AbstractString, repo_path::AbstractString;
repo = try
clone(repo_url, repo_path, clone_opts)
catch err
if isa(err, GitError) && err.code == Error.EAUTH
if isa(err, GitError) && err.code === Error.EAUTH
reject(cred_payload)
else
Base.shred!(cred_payload)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LibGit2/src/rebase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function commit(rb::GitRebase, sig::GitSignature)
oid_ptr, rb.ptr, C_NULL, sig.ptr, C_NULL, C_NULL)
catch err
# TODO: return current HEAD instead
err.code == Error.EAPPLIED && return nothing
err.code === Error.EAPPLIED && return nothing
rethrow()
end
return oid_ptr[]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function completions(string, pos, context_module=Main)::Completions
if isa(ex, Expr)
if ex.head==:call
timholy marked this conversation as resolved.
Show resolved Hide resolved
return complete_methods(ex, context_module), first(frange):method_name_end, false
elseif ex.head==:. && ex.args[2] isa Expr && ex.args[2].head==:tuple
elseif ex.head==:. && ex.args[2] isa Expr && (ex.args[2]::Expr).head==:tuple
timholy marked this conversation as resolved.
Show resolved Hide resolved
return complete_methods(ex, context_module), first(frange):(method_name_end - 1), false
end
end
Expand Down