From 3608c84e6093594fe86923339fc315231492484c Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 5 Nov 2019 17:38:01 -0500 Subject: [PATCH] use `===` for comparison to `nothing` and Symbols (#33764) --- base/Enums.jl | 6 +- base/arraymath.jl | 4 +- base/atomics.jl | 2 +- base/broadcast.jl | 20 +++---- base/cartesian.jl | 24 ++++---- base/channels.jl | 6 +- base/client.jl | 2 +- base/compiler/optimize.jl | 4 +- base/compiler/ssair/driver.jl | 2 +- base/compiler/ssair/inlining.jl | 4 +- base/compiler/ssair/ir.jl | 6 +- base/compiler/ssair/legacy.jl | 4 +- base/compiler/ssair/passes.jl | 2 +- base/compiler/ssair/slot2ssa.jl | 2 +- base/compiler/validation.jl | 4 +- base/deprecated.jl | 8 +-- base/fastmath.jl | 2 +- base/floatfuncs.jl | 2 +- base/gmp.jl | 2 +- base/loading.jl | 10 ++-- base/logging.jl | 10 ++-- base/methodshow.jl | 2 +- base/rational.jl | 4 +- base/reflection.jl | 12 ++-- base/regex.jl | 2 +- base/show.jl | 20 +++---- base/simdloop.jl | 8 +-- base/strings/unicode.jl | 8 +-- base/task.jl | 16 +++--- base/threadcall.jl | 2 +- base/util.jl | 18 +++--- base/views.jl | 8 +-- stdlib/Dates/src/periods.jl | 2 +- stdlib/DelimitedFiles/src/DelimitedFiles.jl | 6 +- stdlib/Distributed/src/cluster.jl | 16 +++--- stdlib/Distributed/src/managers.jl | 4 +- stdlib/FileWatching/src/FileWatching.jl | 2 +- stdlib/InteractiveUtils/src/clipboard.jl | 4 +- stdlib/InteractiveUtils/src/codeview.jl | 6 +- stdlib/InteractiveUtils/src/macros.jl | 2 +- stdlib/LibGit2/src/gitcredential.jl | 2 +- stdlib/LibGit2/src/types.jl | 6 +- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 8 +-- stdlib/LinearAlgebra/src/bidiag.jl | 2 +- stdlib/LinearAlgebra/src/blas.jl | 12 ++-- stdlib/LinearAlgebra/src/bunchkaufman.jl | 10 ++-- stdlib/LinearAlgebra/src/cholesky.jl | 14 ++--- stdlib/LinearAlgebra/src/hessenberg.jl | 2 +- stdlib/LinearAlgebra/src/ldlt.jl | 8 +-- stdlib/LinearAlgebra/src/lq.jl | 4 +- stdlib/LinearAlgebra/src/lu.jl | 16 +++--- stdlib/LinearAlgebra/src/qr.jl | 16 +++--- stdlib/LinearAlgebra/src/schur.jl | 14 ++--- stdlib/LinearAlgebra/src/svd.jl | 14 ++--- stdlib/Markdown/src/GitHub/table.jl | 12 ++-- stdlib/Printf/src/Printf.jl | 4 +- stdlib/Profile/src/Profile.jl | 12 ++-- stdlib/REPL/src/LineEdit.jl | 14 ++--- stdlib/REPL/src/REPL.jl | 4 +- stdlib/REPL/src/REPLCompletions.jl | 12 ++-- stdlib/REPL/src/TerminalMenus/config.jl | 10 ++-- stdlib/REPL/src/Terminals.jl | 2 +- stdlib/SharedArrays/src/SharedArrays.jl | 6 +- stdlib/SparseArrays/src/sparsematrix.jl | 2 +- stdlib/SparseArrays/src/sparsevector.jl | 2 +- stdlib/SuiteSparse/src/cholmod.jl | 10 ++-- stdlib/SuiteSparse/src/spqr.jl | 6 +- stdlib/SuiteSparse/src/umfpack.jl | 16 +++--- stdlib/Test/src/Test.jl | 64 ++++++++++----------- stdlib/Test/src/logging.jl | 18 +++--- 70 files changed, 295 insertions(+), 295 deletions(-) diff --git a/base/Enums.jl b/base/Enums.jl index 54473a716380c..b4c02327dd5e2 100644 --- a/base/Enums.jl +++ b/base/Enums.jl @@ -121,7 +121,7 @@ macro enum(T, syms...) end basetype = Int32 typename = T - if isa(T, Expr) && T.head == :(::) && length(T.args) == 2 && isa(T.args[1], Symbol) + if isa(T, Expr) && T.head === :(::) && length(T.args) == 2 && isa(T.args[1], Symbol) typename = T.args[1] basetype = Core.eval(__module__, T.args[2]) if !isa(basetype, DataType) || !(basetype <: Integer) || !isbitstype(basetype) @@ -137,7 +137,7 @@ macro enum(T, syms...) i = zero(basetype) hasexpr = false - if length(syms) == 1 && syms[1] isa Expr && syms[1].head == :block + if length(syms) == 1 && syms[1] isa Expr && syms[1].head === :block syms = syms[1].args end for s in syms @@ -147,7 +147,7 @@ macro enum(T, syms...) throw(ArgumentError("overflow in value \"$s\" of Enum $typename")) end elseif isa(s, Expr) && - (s.head == :(=) || s.head == :kw) && + (s.head === :(=) || s.head === :kw) && length(s.args) == 2 && isa(s.args[1], Symbol) i = Core.eval(__module__, s.args[2]) # allow exprs, e.g. uint128"1" if !isa(i, Integer) diff --git a/base/arraymath.jl b/base/arraymath.jl index 233490804446d..dfea81dd9d35f 100644 --- a/base/arraymath.jl +++ b/base/arraymath.jl @@ -48,10 +48,10 @@ function +(A::Array, Bs::Array...) end for f in (:/, :\, :*) - if f != :/ + if f !== :/ @eval ($f)(A::Number, B::AbstractArray) = broadcast_preserving_zero_d($f, A, B) end - if f != :\ + if f !== :\ @eval ($f)(A::AbstractArray, B::Number) = broadcast_preserving_zero_d($f, A, B) end end diff --git a/base/atomics.jl b/base/atomics.jl index 241d7a134d8d1..b5446be5e0d99 100644 --- a/base/atomics.jl +++ b/base/atomics.jl @@ -398,7 +398,7 @@ for typ in atomictypes ret $lt %rv """, $typ, Tuple{Ptr{$typ}, $typ}, unsafe_convert(Ptr{$typ}, x), v) else - rmwop == :xchg || continue + rmwop === :xchg || continue @eval $fn(x::Atomic{$typ}, v::$typ) = llvmcall($""" %iptr = inttoptr i$WORD_SIZE %0 to $ilt* diff --git a/base/broadcast.jl b/base/broadcast.jl index ebce0afaba6c1..a27cb7ba74180 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -1144,12 +1144,12 @@ Base.@propagate_inbounds dotview(args...) = Base.maybeview(args...) dottable(x) = false # avoid dotting spliced objects (e.g. view calls inserted by @view) # don't add dots to dot operators dottable(x::Symbol) = (!isoperator(x) || first(string(x)) != '.' || x === :..) && x !== :(:) -dottable(x::Expr) = x.head != :$ +dottable(x::Expr) = x.head !== :$ undot(x) = x function undot(x::Expr) - if x.head == :.= + if x.head === :.= Expr(:(=), x.args...) - elseif x.head == :block # occurs in for x=..., y=... + elseif x.head === :block # occurs in for x=..., y=... Expr(:block, map(undot, x.args)...) else x @@ -1158,22 +1158,22 @@ end __dot__(x) = x function __dot__(x::Expr) dotargs = map(__dot__, x.args) - if x.head == :call && dottable(x.args[1]) + if x.head === :call && dottable(x.args[1]) Expr(:., dotargs[1], Expr(:tuple, dotargs[2:end]...)) - elseif x.head == :comparison + elseif x.head === :comparison Expr(:comparison, (iseven(i) && dottable(arg) && arg isa Symbol && isoperator(arg) ? Symbol('.', arg) : arg for (i, arg) in pairs(dotargs))...) - elseif x.head == :$ + elseif x.head === :$ x.args[1] - elseif x.head == :let # don't add dots to `let x=...` assignments + elseif x.head === :let # don't add dots to `let x=...` assignments Expr(:let, undot(dotargs[1]), dotargs[2]) - elseif x.head == :for # don't add dots to for x=... assignments + elseif x.head === :for # don't add dots to for x=... assignments Expr(:for, undot(dotargs[1]), dotargs[2]) - elseif (x.head == :(=) || x.head == :function || x.head == :macro) && + elseif (x.head === :(=) || x.head === :function || x.head === :macro) && Meta.isexpr(x.args[1], :call) # function or macro definition Expr(x.head, x.args[1], dotargs[2]) else - if x.head == :&& || x.head == :|| + if x.head === :&& || x.head === :|| error(""" Using `&&` and `||` is disallowed in `@.` expressions. Use `&` or `|` for elementwise logical operations. diff --git a/base/cartesian.jl b/base/cartesian.jl index 865b766664708..45276e918b17c 100644 --- a/base/cartesian.jl +++ b/base/cartesian.jl @@ -45,7 +45,7 @@ function _nloops(N::Int, itersym::Symbol, arraysym::Symbol, args::Expr...) end function _nloops(N::Int, itersym::Symbol, rangeexpr::Expr, args::Expr...) - if rangeexpr.head != :-> + if rangeexpr.head !== :-> throw(ArgumentError("second argument must be an anonymous function expression to compute the range")) end if !(1 <= length(args) <= 3) @@ -167,7 +167,7 @@ evaluate to `true`. can be convenient for bounds-checking. """ macro nall(N::Int, criterion::Expr) - if criterion.head != :-> + if criterion.head !== :-> throw(ArgumentError("second argument must be an anonymous function expression yielding the criterion")) end conds = Any[ Expr(:escape, inlineanonymous(criterion, i)) for i = 1:N ] @@ -183,7 +183,7 @@ evaluate to `true`. `@nany 3 d->(i_d > 1)` would generate the expression `(i_1 > 1 || i_2 > 1 || i_3 > 1)`. """ macro nany(N::Int, criterion::Expr) - if criterion.head != :-> + if criterion.head !== :-> error("Second argument must be an anonymous function expression yielding the criterion") end conds = Any[ Expr(:escape, inlineanonymous(criterion, i)) for i = 1:N ] @@ -233,7 +233,7 @@ end # Simplify expressions like :(d->3:size(A,d)-3) given an explicit value for d function inlineanonymous(ex::Expr, val) - if ex.head != :-> + if ex.head !== :-> throw(ArgumentError("not an anonymous function")) end if !isa(ex.args[1], Symbol) @@ -313,7 +313,7 @@ end function lreplace!(ex::Expr, r::LReplace) # Curly-brace notation, which acts like parentheses - if ex.head == :curly && length(ex.args) == 2 && isa(ex.args[1], Symbol) && endswith(string(ex.args[1]), "_") + if ex.head === :curly && length(ex.args) == 2 && isa(ex.args[1], Symbol) && endswith(string(ex.args[1]), "_") excurly = exprresolve(lreplace!(ex.args[2], r)) if isa(excurly, Number) return Symbol(ex.args[1],excurly) @@ -333,12 +333,12 @@ lreplace!(arg, r::LReplace) = arg poplinenum(arg) = arg function poplinenum(ex::Expr) - if ex.head == :block + if ex.head === :block if length(ex.args) == 1 return ex.args[1] elseif length(ex.args) == 2 && isa(ex.args[1], LineNumberNode) return ex.args[2] - elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].head == :line) + elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].head === :line) return ex.args[2] end end @@ -353,7 +353,7 @@ 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)]) + 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]...) end false, 0 @@ -362,7 +362,7 @@ 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) + 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]) end false, false @@ -378,12 +378,12 @@ function exprresolve(ex::Expr) can_eval, result = exprresolve_arith(ex) if can_eval return result - elseif ex.head == :call && (ex.args[1] == :+ || ex.args[1] == :-) && length(ex.args) == 3 && ex.args[3] == 0 + elseif ex.head === :call && (ex.args[1] === :+ || ex.args[1] === :-) && length(ex.args) == 3 && ex.args[3] == 0 # simplify x+0 and x-0 return ex.args[2] end # Resolve array references - if ex.head == :ref && isa(ex.args[1], Array) + if ex.head === :ref && isa(ex.args[1], Array) for i = 2:length(ex.args) if !isa(ex.args[i], Real) return ex @@ -392,7 +392,7 @@ function exprresolve(ex::Expr) return ex.args[1][ex.args[2:end]...] end # Resolve conditionals - if ex.head == :if + if ex.head === :if can_eval, tf = exprresolve_conditional(ex.args[1]) if can_eval ex = tf ? ex.args[2] : ex.args[3] diff --git a/base/channels.jl b/base/channels.jl index 606a3b2dec7d9..fdb520868f584 100644 --- a/base/channels.jl +++ b/base/channels.jl @@ -31,7 +31,7 @@ mutable struct Channel{T} <: AbstractChannel{T} cond_wait::Threads.Condition # waiting for data to become maybe available cond_put::Threads.Condition # waiting for a writeable slot state::Symbol - excp::Union{Exception, Nothing} # exception to be thrown when state != :open + excp::Union{Exception, Nothing} # exception to be thrown when state !== :open data::Vector{T} sz_max::Int # maximum size of channel @@ -189,7 +189,7 @@ function close(c::Channel, excp::Exception=closed_exception()) end nothing end -isopen(c::Channel) = (c.state == :open) +isopen(c::Channel) = (c.state === :open) """ bind(chnl::Channel, task::Task) @@ -459,7 +459,7 @@ function iterate(c::Channel, state=nothing) try return (take!(c), nothing) catch e - if isa(e, InvalidStateException) && e.state == :closed + if isa(e, InvalidStateException) && e.state === :closed return nothing else rethrow() diff --git a/base/client.jl b/base/client.jl index 8f5a89fbb8666..0c6eff620bf73 100644 --- a/base/client.jl +++ b/base/client.jl @@ -94,7 +94,7 @@ function scrub_repl_backtrace(bt) if bt !== nothing && !(bt isa Vector{Any}) # ignore our sentinel value types bt = stacktrace(bt) # remove REPL-related frames from interactive printing - eval_ind = findlast(frame -> !frame.from_c && frame.func == :eval, bt) + eval_ind = findlast(frame -> !frame.from_c && frame.func === :eval, bt) eval_ind === nothing || deleteat!(bt, eval_ind:length(bt)) end return bt diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index a208156274496..c0039084bcd3d 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -157,7 +157,7 @@ function stmt_affects_purity(@nospecialize(stmt), ir) return !(t ⊑ Bool) end if isa(stmt, Expr) - return stmt.head != :loopinfo && stmt.head != :enter + return stmt.head !== :loopinfo && stmt.head !== :enter end return true end @@ -167,7 +167,7 @@ function optimize(opt::OptimizationState, @nospecialize(result)) def = opt.linfo.def nargs = Int(opt.nargs) - 1 @timeit "optimizer" ir = run_passes(opt.src, nargs, opt) - force_noinline = _any(@nospecialize(x) -> isexpr(x, :meta) && x.args[1] == :noinline, ir.meta) + force_noinline = _any(@nospecialize(x) -> isexpr(x, :meta) && x.args[1] === :noinline, ir.meta) # compute inlining and other related optimizations if (isa(result, Const) || isconstType(result)) diff --git a/base/compiler/ssair/driver.jl b/base/compiler/ssair/driver.jl index 8f00e39cab03b..cb05e7e414311 100644 --- a/base/compiler/ssair/driver.jl +++ b/base/compiler/ssair/driver.jl @@ -34,7 +34,7 @@ end function normalize(@nospecialize(stmt), meta::Vector{Any}) if isa(stmt, Expr) - if stmt.head == :meta + if stmt.head === :meta args = stmt.args if length(args) > 0 push!(meta, stmt) diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index 7f1325ad84c09..cbfb70b1cf156 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -383,7 +383,7 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector end elseif isa(stmt′, GotoNode) stmt′ = GotoNode(stmt′.label + bb_offset) - elseif isa(stmt′, Expr) && stmt′.head == :enter + elseif isa(stmt′, Expr) && stmt′.head === :enter stmt′ = Expr(:enter, stmt′.args[1] + bb_offset) elseif isa(stmt′, GotoIfNot) stmt′ = GotoIfNot(stmt′.cond, stmt′.dest + bb_offset) @@ -560,7 +560,7 @@ function batch_inline!(todo::Vector{Any}, ir::IRCode, linetable::Vector{LineInfo end elseif isa(stmt, GotoNode) compact[idx] = GotoNode(state.bb_rename[stmt.label]) - elseif isa(stmt, Expr) && stmt.head == :enter + elseif isa(stmt, Expr) && stmt.head === :enter compact[idx] = Expr(:enter, state.bb_rename[stmt.args[1]]) elseif isa(stmt, GotoIfNot) compact[idx] = GotoIfNot(stmt.cond, state.bb_rename[stmt.dest]) diff --git a/base/compiler/ssair/ir.jl b/base/compiler/ssair/ir.jl index 665387c1143b6..45184203a7fdb 100644 --- a/base/compiler/ssair/ir.jl +++ b/base/compiler/ssair/ir.jl @@ -80,7 +80,7 @@ function basic_blocks_starts(stmts::Vector{Any}) if stmt.head === :leave # :leave terminates a BB push!(jump_dests, idx+1) - elseif stmt.head == :enter + elseif stmt.head === :enter # :enter starts/ends a BB push!(jump_dests, idx) push!(jump_dests, idx+1) @@ -151,7 +151,7 @@ function compute_basic_blocks(stmts::Vector{Any}) push!(b.succs, block′) end elseif isa(terminator, Expr) - if terminator.head == :enter + if terminator.head === :enter # :enter gets a virtual edge to the exception handler and # the exception handler gets a virtual edge from outside # the function. @@ -162,7 +162,7 @@ function compute_basic_blocks(stmts::Vector{Any}) push!(blocks[block′].preds, num) push!(blocks[block′].preds, 0) push!(b.succs, block′) - elseif terminator.head == :gotoifnot + elseif terminator.head === :gotoifnot block′ = block_for_inst(basic_block_index, terminator.args[2]::Int) if block′ == num + 1 # This GotoIfNot acts like a noop - treat it as such. diff --git a/base/compiler/ssair/legacy.jl b/base/compiler/ssair/legacy.jl index 038bd75daa011..66e830046eaf3 100644 --- a/base/compiler/ssair/legacy.jl +++ b/base/compiler/ssair/legacy.jl @@ -35,7 +35,7 @@ function inflate_ir(ci::CodeInfo, sptypes::Vector{Any}, argtypes::Vector{Any}) code[i] = GotoIfNot(stmt.cond, block_for_inst(cfg, stmt.dest)) elseif isa(stmt, PhiNode) code[i] = PhiNode(Any[block_for_inst(cfg, edge) for edge in stmt.edges], stmt.values) - elseif isa(stmt, Expr) && stmt.head == :enter + elseif isa(stmt, Expr) && stmt.head === :enter stmt.args[1] = block_for_inst(cfg, stmt.args[1]) code[i] = stmt else @@ -87,7 +87,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int) else ci.code[i] = Expr(:unreachable) end - elseif isa(stmt, Expr) && stmt.head == :enter + elseif isa(stmt, Expr) && stmt.head === :enter stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]].stmts) ci.code[i] = stmt else diff --git a/base/compiler/ssair/passes.jl b/base/compiler/ssair/passes.jl index ae53dd87d41f3..f30860c0324ea 100644 --- a/base/compiler/ssair/passes.jl +++ b/base/compiler/ssair/passes.jl @@ -571,7 +571,7 @@ function getfield_elim_pass!(ir::IRCode, domtree::DomTree) (isa(c1, Const) && isa(c2, Const)) && continue lift_comparison!(compact, idx, c1, c2, stmt, lifting_cache) continue - elseif isexpr(stmt, :call) && stmt.args[1] == :unchecked_getfield + elseif isexpr(stmt, :call) && stmt.args[1] === :unchecked_getfield is_getfield = true is_unchecked = true elseif isexpr(stmt, :foreigncall) diff --git a/base/compiler/ssair/slot2ssa.jl b/base/compiler/ssair/slot2ssa.jl index a2ee23efaecf9..a15c03758fc8d 100644 --- a/base/compiler/ssair/slot2ssa.jl +++ b/base/compiler/ssair/slot2ssa.jl @@ -475,7 +475,7 @@ function domsort_ssa!(ir::IRCode, domtree::DomTree) end result_stmts[inst_range[end]] = GotoIfNot(terminator.cond, bb_rename[terminator.dest]) elseif !isa(terminator, ReturnNode) - if isa(terminator, Expr) && terminator.head == :enter + if isa(terminator, Expr) && terminator.head === :enter terminator.args[1] = bb_rename[terminator.args[1]] end if bb_rename[bb + 1] != new_bb + 1 diff --git a/base/compiler/validation.jl b/base/compiler/validation.jl index 1dafa43644ff3..e02327cbb663b 100644 --- a/base/compiler/validation.jl +++ b/base/compiler/validation.jl @@ -139,9 +139,9 @@ function validate_code!(errors::Vector{>:InvalidCodeError}, c::CodeInfo, is_top_ push!(errors, InvalidCodeError(INVALID_RETURN, x.args[1])) end validate_val!(x.args[1]) - elseif head === :call || head === :invoke || head == :gc_preserve_end || head === :meta || + elseif head === :call || head === :invoke || head === :gc_preserve_end || head === :meta || head === :inbounds || head === :foreigncall || head === :cfunction || - head === :const || head === :enter || head === :leave || head == :pop_exception || + head === :const || head === :enter || head === :leave || head === :pop_exception || head === :method || head === :global || head === :static_parameter || head === :new || head === :splatnew || head === :thunk || head === :loopinfo || head === :throw_undef_if_not || head === :unreachable diff --git a/base/deprecated.jl b/base/deprecated.jl index 21131cf857632..fd8e42c46427b 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -42,16 +42,16 @@ macro deprecate(old, new, ex=true) depwarn($"`$old` is deprecated, use `$new` instead.", Core.Typeof($(esc(old))).name.mt.name) $(esc(new))(args...) end)) - elseif isa(old, Expr) && (old.head == :call || old.head == :where) + elseif isa(old, Expr) && (old.head === :call || old.head === :where) remove_linenums!(new) oldcall = sprint(show_unquoted, old) newcall = sprint(show_unquoted, new) # if old.head is a :where, step down one level to the :call to avoid code duplication below - callexpr = old.head == :call ? old : old.args[1] - if callexpr.head == :call + callexpr = old.head === :call ? old : old.args[1] + if callexpr.head === :call if isa(callexpr.args[1], Symbol) oldsym = callexpr.args[1]::Symbol - elseif isa(callexpr.args[1], Expr) && callexpr.args[1].head == :curly + elseif isa(callexpr.args[1], Expr) && callexpr.args[1].head === :curly oldsym = callexpr.args[1].args[1]::Symbol else error("invalid usage of @deprecate") diff --git a/base/fastmath.jl b/base/fastmath.jl index c0475b316122d..d8159ba38bf67 100644 --- a/base/fastmath.jl +++ b/base/fastmath.jl @@ -91,7 +91,7 @@ const rewrite_op = function make_fastmath(expr::Expr) if expr.head === :quote return expr - elseif expr.head == :call && expr.args[1] == :^ && expr.args[3] isa Integer + elseif expr.head === :call && expr.args[1] === :^ && expr.args[3] isa Integer # mimic Julia's literal_pow lowering of literal integer powers return Expr(:call, :(Base.FastMath.pow_fast), make_fastmath(expr.args[2]), Val{expr.args[3]}()) end diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index 9c90137e0d4fc..8c934284a44ad 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -313,7 +313,7 @@ fma_llvm(x::Float64, y::Float64, z::Float64) = fma_float(x, y, z) # 1.0000000009313226 = 1 + 1/2^30 # If fma_llvm() clobbers the rounding mode, the result of 0.1 + 0.2 will be 0.3 # instead of the properly-rounded 0.30000000000000004; check after calling fma -if (Sys.ARCH != :i686 && fma_llvm(1.0000305f0, 1.0000305f0, -1.0f0) == 6.103609f-5 && +if (Sys.ARCH !== :i686 && fma_llvm(1.0000305f0, 1.0000305f0, -1.0f0) == 6.103609f-5 && (fma_llvm(1.0000000009313226, 1.0000000009313226, -1.0) == 1.8626451500983188e-9) && 0.1 + 0.2 == 0.30000000000000004) fma(x::Float32, y::Float32, z::Float32) = fma_llvm(x,y,z) diff --git a/base/gmp.jl b/base/gmp.jl index 32f21b8b9577b..10ee49e49f22c 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -188,7 +188,7 @@ for op in (:neg, :com, :sqrt, :set) $op!(x::BigInt, a::BigInt) = (ccall($(gmpz(op)), Cvoid, (mpz_t, mpz_t), x, a); x) $op(a::BigInt) = $op!(BigInt(), a) end - op == :set && continue # MPZ.set!(x) would make no sense + op === :set && continue # MPZ.set!(x) would make no sense @eval $op!(x::BigInt) = $op!(x, x) end diff --git a/base/loading.jl b/base/loading.jl index 9cb58e67ea874..8c9efe1f63cc4 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -490,15 +490,15 @@ function explicit_project_deps_get(project_file::String, name::String)::Union{No state = :top for line in eachline(io) if occursin(re_section, line) - state == :top && root_name == name && return root_uuid + state === :top && root_name == name && return root_uuid state = occursin(re_section_deps, line) ? :deps : :other - elseif state == :top + elseif state === :top if (m = match(re_name_to_string, line)) !== nothing root_name = String(m.captures[1]) elseif (m = match(re_uuid_to_string, line)) !== nothing root_uuid = UUID(m.captures[1]) end - elseif state == :deps + elseif state === :deps if (m = match(re_key_to_string, line)) !== nothing m.captures[1] == name && return UUID(m.captures[2]) end @@ -523,7 +523,7 @@ function explicit_manifest_deps_get(project_file::String, where::UUID, name::Str uuid == where && break uuid = deps = nothing state = :stanza - elseif state == :stanza + elseif state === :stanza if (m = match(re_uuid_to_string, line)) !== nothing uuid = UUID(m.captures[1]) elseif (m = match(re_deps_to_any, line)) !== nothing @@ -533,7 +533,7 @@ function explicit_manifest_deps_get(project_file::String, where::UUID, name::Str elseif occursin(re_section, line) state = :other end - elseif state == :deps && uuid == where + elseif state === :deps && uuid == where # [deps] section format gives both name and uuid if (m = match(re_key_to_string, line)) !== nothing m.captures[1] == name && return UUID(m.captures[2]) diff --git a/base/logging.jl b/base/logging.jl index 381be2f69f891..0de8ae9337374 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -261,20 +261,20 @@ function logmsg_code(_module, file, line, level, message, exs...) end k = ex.args[1] # Recognize several special keyword arguments - if k == :_id + if k === :_id # id may be overridden if you really want several log # statements to share the same id (eg, several pertaining to # the same progress step). In those cases it may be wise to # manually call log_record_id to get a unique id in the same # format. id = esc(v) - elseif k == :_module + elseif k === :_module _module = esc(v) - elseif k == :_line + elseif k === :_line line = esc(v) - elseif k == :_file + elseif k === :_file file = esc(v) - elseif k == :_group + elseif k === :_group group = esc(v) else # Copy across key value pairs for structured log records diff --git a/base/methodshow.jl b/base/methodshow.jl index 18bd7dfccd3b8..e51165faee248 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -296,7 +296,7 @@ fileurl(file) = let f = find_source_file(file); f === nothing ? "" : "file://"*f function url(m::Method) M = m.module - (m.file == :null || m.file == :string) && return "" + (m.file === :null || m.file === :string) && return "" file = string(m.file) line = m.line line <= 0 || occursin(r"In\[[0-9]+\]", file) && return "" diff --git a/base/rational.jl b/base/rational.jl index 0140cf8bedec0..6e7bb6eb52746 100644 --- a/base/rational.jl +++ b/base/rational.jl @@ -299,11 +299,11 @@ for rel in (:<,:<=,:cmp) for (Tx,Ty) in ((Rational,AbstractFloat), (AbstractFloat,Rational)) @eval function ($rel)(x::$Tx, y::$Ty) if isnan(x) - $(rel == :cmp ? :(return isnan(y) ? 0 : 1) : + $(rel === :cmp ? :(return isnan(y) ? 0 : 1) : :(return false)) end if isnan(y) - $(rel == :cmp ? :(return -1) : + $(rel === :cmp ? :(return -1) : :(return false)) end diff --git a/base/reflection.jl b/base/reflection.jl index 813ab0f4bc1ee..b8548356362c4 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -792,10 +792,10 @@ Note that an error will be thrown if `types` are not leaf types when `generated` function code_lowered(@nospecialize(f), @nospecialize(t=Tuple); generated::Bool=true, debuginfo::Symbol=:default) if @isdefined(IRShow) debuginfo = IRShow.debuginfo(debuginfo) - elseif debuginfo == :default + elseif debuginfo === :default debuginfo = :source end - if debuginfo != :source && debuginfo != :none + if debuginfo !== :source && debuginfo !== :none throw(ArgumentError("'debuginfo' must be either :source or :none")) end return map(method_instances(f, t)) do m @@ -809,7 +809,7 @@ function code_lowered(@nospecialize(f), @nospecialize(t=Tuple); generated::Bool= end end code = uncompressed_ast(m.def::Method) - debuginfo == :none && remove_linenums!(code) + debuginfo === :none && remove_linenums!(code) return code end end @@ -1079,10 +1079,10 @@ function code_typed(@nospecialize(f), @nospecialize(types=Tuple); end if @isdefined(IRShow) debuginfo = IRShow.debuginfo(debuginfo) - elseif debuginfo == :default + elseif debuginfo === :default debuginfo = :source end - if debuginfo != :source && debuginfo != :none + if debuginfo !== :source && debuginfo !== :none throw(ArgumentError("'debuginfo' must be either :source or :none")) end types = to_tuple_type(types) @@ -1091,7 +1091,7 @@ function code_typed(@nospecialize(f), @nospecialize(types=Tuple); meth = func_for_method_checked(x[3], types, x[2]) (code, ty) = Core.Compiler.typeinf_code(meth, x[1], x[2], optimize, params) code === nothing && error("inference not successful") # inference disabled? - debuginfo == :none && remove_linenums!(code) + debuginfo === :none && remove_linenums!(code) push!(asts, code => ty) end return asts diff --git a/base/regex.jl b/base/regex.jl index 5c1ba8c37e956..0f5074bf026f8 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -643,7 +643,7 @@ function *(r1::Union{Regex,AbstractString,AbstractChar}, rs::Union{Regex,Abstrac shared = mask for r in (r1, rs...) r isa Regex || continue - if match_opts == nothing + if match_opts === nothing match_opts = r.match_options compile_opts = r.compile_options & ~mask else diff --git a/base/show.jl b/base/show.jl index aa780abe31ef1..431207e9f53f7 100644 --- a/base/show.jl +++ b/base/show.jl @@ -195,7 +195,7 @@ end function show(io::IO, ::MIME"text/plain", t::Task) show(io, t) - if t.state == :failed + if t.state === :failed println(io) showerror(io, CapturedException(t.result, t.backtrace)) end @@ -495,7 +495,7 @@ function show(io::IO, @nospecialize(x::Type)) return show(io, unwrap_unionall(x).name) end - if x.var.name == :_ || io_has_tvar_name(io, x.var.name, x) + if x.var.name === :_ || io_has_tvar_name(io, x.var.name, x) counter = 1 while true newname = Symbol(x.var.name, counter) @@ -1013,7 +1013,7 @@ end function show_call(io::IO, head, func, func_args, indent) op, cl = expr_calls[head] if (isa(func, Symbol) && func !== :(:) && !(head === :. && isoperator(func))) || - (isa(func, Expr) && (func.head == :. || func.head == :curly || func.head == :macroname)) || + (isa(func, Expr) && (func.head === :. || func.head === :curly || func.head === :macroname)) || isa(func, GlobalRef) show_unquoted(io, func, indent) else @@ -1021,7 +1021,7 @@ function show_call(io::IO, head, func, func_args, indent) show_unquoted(io, func, indent) print(io, ')') end - if head == :(.) + if head === :(.) print(io, '.') end if !isempty(func_args) && isa(func_args[1], Expr) && func_args[1].head === :parameters @@ -1152,7 +1152,7 @@ function show_import_path(io::IO, ex) end elseif ex.head === :(.) for i = 1:length(ex.args) - if i > 1 && ex.args[i-1] != :(.) + if i > 1 && ex.args[i-1] !== :(.) print(io, '.') end show_sym(io, ex.args[i], allow_macroname=(i==length(ex.args))) @@ -1287,7 +1287,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) # other call-like expressions ("A[1,2]", "T{X,Y}", "f.(X,Y)") elseif haskey(expr_calls, head) && nargs >= 1 # :ref/:curly/:calldecl/:(.) - funcargslike = head == :(.) ? args[2].args : args[2:end] + funcargslike = head === :(.) ? args[2].args : args[2:end] show_call(io, head, args[1], funcargslike, indent) # comprehensions @@ -1350,7 +1350,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) elseif (head === :if || head === :elseif) && nargs == 3 show_block(io, head, args[1], args[2], indent) - if isa(args[3],Expr) && args[3].head == :elseif + if isa(args[3],Expr) && args[3].head === :elseif show_unquoted(io, args[3], indent, prec) else show_block(io, "else", args[3], indent) @@ -1613,7 +1613,7 @@ resolvebinding(@nospecialize(ex)) = ex resolvebinding(ex::QuoteNode) = ex.value resolvebinding(ex::Symbol) = resolvebinding(GlobalRef(Main, ex)) function resolvebinding(ex::Expr) - if ex.head == :. && isa(ex.args[2], Symbol) + if ex.head === :. && isa(ex.args[2], Symbol) parent = resolvebinding(ex.args[1]) if isa(parent, Module) return resolvebinding(GlobalRef(parent, ex.args[2])) @@ -1630,7 +1630,7 @@ function resolvebinding(ex::GlobalRef) end function ismodulecall(ex::Expr) - return ex.head == :call && (ex.args[1] === GlobalRef(Base,:getfield) || + return ex.head === :call && (ex.args[1] === GlobalRef(Base,:getfield) || ex.args[1] === GlobalRef(Core,:getfield)) && isa(resolvebinding(ex.args[2]), Module) end @@ -1687,7 +1687,7 @@ module IRShow :none => src -> Base.IRShow.lineinfo_disabled, ) const default_debuginfo = Ref{Symbol}(:none) - debuginfo(sym) = sym == :default ? default_debuginfo[] : sym + debuginfo(sym) = sym === :default ? default_debuginfo[] : sym end function show(io::IO, src::CodeInfo; debuginfo::Symbol=:source) diff --git a/base/simdloop.jl b/base/simdloop.jl index 0fdedba06e1cd..933a309461d38 100644 --- a/base/simdloop.jl +++ b/base/simdloop.jl @@ -15,7 +15,7 @@ end # symbol '=' range # symbol 'in' range function parse_iteration_space(x) - (isa(x, Expr) && (x.head == :(=) || x.head == :in)) || throw(SimdError("= or in expected")) + (isa(x, Expr) && (x.head === :(=) || x.head === :in)) || throw(SimdError("= or in expected")) length(x.args) == 2 || throw(SimdError("simd range syntax is wrong")) isa(x.args[1], Symbol) || throw(SimdError("simd loop index must be a symbol")) x.args # symbol, range @@ -23,7 +23,7 @@ end # reject invalid control flow statements in @simd loop body function check_body!(x::Expr) - if x.head === :break || x.head == :continue + if x.head === :break || x.head === :continue throw(SimdError("$(x.head) is not allowed inside a @simd loop body")) elseif x.head === :macrocall && x.args[1] === Symbol("@goto") throw(SimdError("$(x.args[1]) is not allowed inside a @simd loop body")) @@ -55,7 +55,7 @@ simd_outer_range(r) = 0:0 # Compile Expr x in context of @simd. function compile(x, ivdep) - (isa(x, Expr) && x.head == :for) || throw(SimdError("for loop expected")) + (isa(x, Expr) && x.head === :for) || throw(SimdError("for loop expected")) length(x.args) == 2 || throw(SimdError("1D for loop expected")) check_body!(x) @@ -129,7 +129,7 @@ macro simd(forloop) end macro simd(ivdep, forloop) - if ivdep == :ivdep + if ivdep === :ivdep esc(compile(forloop, Symbol("julia.ivdep"))) else throw(SimdError("Only ivdep is valid as the first argument to @simd")) diff --git a/base/strings/unicode.jl b/base/strings/unicode.jl index f203e2751301a..5d5bc93ef592b 100644 --- a/base/strings/unicode.jl +++ b/base/strings/unicode.jl @@ -198,11 +198,11 @@ function normalize( end function normalize(s::AbstractString, nf::Symbol) - utf8proc_map(s, nf == :NFC ? (UTF8PROC_STABLE | UTF8PROC_COMPOSE) : - nf == :NFD ? (UTF8PROC_STABLE | UTF8PROC_DECOMPOSE) : - nf == :NFKC ? (UTF8PROC_STABLE | UTF8PROC_COMPOSE + utf8proc_map(s, nf === :NFC ? (UTF8PROC_STABLE | UTF8PROC_COMPOSE) : + nf === :NFD ? (UTF8PROC_STABLE | UTF8PROC_DECOMPOSE) : + nf === :NFKC ? (UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT) : - nf == :NFKD ? (UTF8PROC_STABLE | UTF8PROC_DECOMPOSE + nf === :NFKD ? (UTF8PROC_STABLE | UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT) : throw(ArgumentError(":$nf is not one of :NFC, :NFD, :NFKC, :NFKD"))) end diff --git a/base/task.jl b/base/task.jl index 25b2459160b95..1814f042d7475 100644 --- a/base/task.jl +++ b/base/task.jl @@ -141,7 +141,7 @@ julia> istaskdone(b) true ``` """ -istaskdone(t::Task) = ((t.state == :done) | istaskfailed(t)) +istaskdone(t::Task) = ((t.state === :done) | istaskfailed(t)) """ istaskstarted(t::Task) -> Bool @@ -182,7 +182,7 @@ julia> istaskfailed(b) true ``` """ -istaskfailed(t::Task) = (t.state == :failed) +istaskfailed(t::Task) = (t.state === :failed) Threads.threadid(t::Task) = Int(ccall(:jl_get_task_tid, Int16, (Any,), t)+1) @@ -390,7 +390,7 @@ function task_done_hook(t::Task) if err && !handled && Threads.threadid() == 1 if isa(result, InterruptException) && isdefined(Base, :active_repl_backend) && - active_repl_backend.backend_task.state == :runnable && isempty(Workqueue) && + active_repl_backend.backend_task.state === :runnable && isempty(Workqueue) && active_repl_backend.in_eval throwto(active_repl_backend.backend_task, result) # this terminates the task end @@ -405,7 +405,7 @@ function task_done_hook(t::Task) # issue #19467 if Threads.threadid() == 1 && isa(e, InterruptException) && isdefined(Base, :active_repl_backend) && - active_repl_backend.backend_task.state == :runnable && isempty(Workqueue) && + active_repl_backend.backend_task.state === :runnable && isempty(Workqueue) && active_repl_backend.in_eval throwto(active_repl_backend.backend_task, e) else @@ -482,7 +482,7 @@ function __preinit_threads__() end function enq_work(t::Task) - (t.state == :runnable && t.queue === nothing) || error("schedule: Task not runnable") + (t.state === :runnable && t.queue === nothing) || error("schedule: Task not runnable") tid = Threads.threadid(t) # Note there are three reasons a Task might be put into a sticky queue # even if t.sticky == false: @@ -542,7 +542,7 @@ true """ function schedule(t::Task, @nospecialize(arg); error=false) # schedule a task to be (re)started with the given value or exception - t.state == :runnable || Base.error("schedule: Task not runnable") + t.state === :runnable || Base.error("schedule: Task not runnable") if error t.queue === nothing || Base.list_deletefirst!(t.queue, t) t.exception = arg @@ -624,7 +624,7 @@ end function ensure_rescheduled(othertask::Task) ct = current_task() W = Workqueues[Threads.threadid()] - if ct !== othertask && othertask.state == :runnable + if ct !== othertask && othertask.state === :runnable # we failed to yield to othertask # return it to the head of a queue to be retried later tid = Threads.threadid(othertask) @@ -641,7 +641,7 @@ end function trypoptask(W::StickyWorkqueue) isempty(W) && return t = popfirst!(W) - if t.state != :runnable + if t.state !== :runnable # assume this somehow got queued twice, # probably broken now, but try discarding this switch and keep going # can't throw here, because it's probably not the fault of the caller to wait diff --git a/base/threadcall.jl b/base/threadcall.jl index 4754afec0d6ac..2267e4ea2228c 100644 --- a/base/threadcall.jl +++ b/base/threadcall.jl @@ -18,7 +18,7 @@ Note that the called function should never call back into Julia. """ macro threadcall(f, rettype, argtypes, argvals...) # check for usage errors - isa(argtypes,Expr) && argtypes.head == :tuple || + isa(argtypes,Expr) && argtypes.head === :tuple || error("threadcall: argument types must be a tuple") length(argtypes.args) == length(argvals) || error("threadcall: wrong number of arguments to C function") diff --git a/base/util.jl b/base/util.jl index 1688d5ef62b74..fdb8a688cfe00 100644 --- a/base/util.jl +++ b/base/util.jl @@ -377,7 +377,7 @@ function with_output_color(f::Function, color::Union{Int, Symbol}, io::IO, args. if !iscolor print(io, str) else - bold && color == :bold && (color = :nothing) + bold && color === :bold && (color = :nothing) enable_ansi = get(text_colors, color, text_colors[:default]) * (bold ? text_colors[:bold] : "") disable_ansi = (bold ? disable_text_style[:bold] : "") * @@ -714,9 +714,9 @@ Stacktrace: """ macro kwdef(expr) expr = macroexpand(__module__, expr) # to expand @static - expr isa Expr && expr.head == :struct || error("Invalid usage of @kwdef") + expr isa Expr && expr.head === :struct || error("Invalid usage of @kwdef") T = expr.args[2] - if T isa Expr && T.head == :<: + if T isa Expr && T.head === :<: T = T.args[1] end @@ -729,13 +729,13 @@ macro kwdef(expr) if !isempty(params_ex.args) if T isa Symbol kwdefs = :(($(esc(T)))($params_ex) = ($(esc(T)))($(call_args...))) - elseif T isa Expr && T.head == :curly + elseif T isa Expr && T.head === :curly # if T == S{A<:AA,B<:BB}, define two methods # S(...) = ... # S{A,B}(...) where {A<:AA,B<:BB} = ... S = T.args[1] P = T.args[2:end] - Q = [U isa Expr && U.head == :<: ? U.args[1] : U for U in P] + Q = [U isa Expr && U.head === :<: ? U.args[1] : U for U in P] SQ = :($S{$(Q...)}) kwdefs = quote ($(esc(S)))($params_ex) =($(esc(S)))($(call_args...)) @@ -764,12 +764,12 @@ function _kwdef!(blk, params_args, call_args) push!(params_args, ei) push!(call_args, ei) elseif ei isa Expr - if ei.head == :(=) + if ei.head === :(=) lhs = ei.args[1] if lhs isa Symbol # var = defexpr var = lhs - elseif lhs isa Expr && lhs.head == :(::) && lhs.args[1] isa Symbol + elseif lhs isa Expr && lhs.head === :(::) && lhs.args[1] isa Symbol # var::T = defexpr var = lhs.args[1] else @@ -781,12 +781,12 @@ function _kwdef!(blk, params_args, call_args) push!(params_args, Expr(:kw, var, esc(defexpr))) push!(call_args, var) blk.args[i] = lhs - elseif ei.head == :(::) && ei.args[1] isa Symbol + elseif ei.head === :(::) && ei.args[1] isa Symbol # var::Typ var = ei.args[1] push!(params_args, var) push!(call_args, var) - elseif ei.head == :block + elseif ei.head === :block # can arise with use of @static inside type decl _kwdef!(ei, params_args, call_args) end diff --git a/base/views.jl b/base/views.jl index 915ba0a9e7d64..b1be0dc0962a8 100644 --- a/base/views.jl +++ b/base/views.jl @@ -18,11 +18,11 @@ replace_ref_end!(ex) = replace_ref_end_!(ex, nothing)[1] # replace_ref_end_!(ex,withex) returns (new ex, whether withex was used) function replace_ref_end_!(ex, withex) used_withex = false - if isa(ex,Symbol) && ex == :end + if isa(ex,Symbol) && ex === :end withex === nothing && error("Invalid use of end") return withex, true elseif isa(ex,Expr) - if ex.head == :ref + if ex.head === :ref ex.args[1], used_withex = replace_ref_end_!(ex.args[1],withex) S = isa(ex.args[1],Symbol) ? ex.args[1]::Symbol : gensym(:S) # temp var to cache ex.args[1] if needed used_S = false # whether we actually need S @@ -40,7 +40,7 @@ function replace_ref_end_!(ex, withex) exj, used = replace_ref_end_!(ex.args[j],:($lastindex($S,$n))) used_S |= used ex.args[j] = exj - if isa(exj,Expr) && exj.head == :... + if isa(exj,Expr) && exj.head === :... # splatted object exjs = exj.args[1] n = :($n + length($exjs)) @@ -141,7 +141,7 @@ function _views(ex::Expr) Expr(ex.head, Meta.isexpr(lhs, :ref) ? Expr(:ref, _views.(lhs.args)...) : _views(lhs), _views(ex.args[2])) - elseif ex.head == :ref + elseif ex.head === :ref Expr(:call, maybeview, _views.(ex.args)...) else h = string(ex.head) diff --git a/stdlib/Dates/src/periods.jl b/stdlib/Dates/src/periods.jl index 5b6d609ec7936..db2b773ed661d 100644 --- a/stdlib/Dates/src/periods.jl +++ b/stdlib/Dates/src/periods.jl @@ -24,7 +24,7 @@ for period in (:Year, :Month, :Week, :Day, :Hour, :Minute, :Second, :Millisecond # Period accessors typs = period in (:Microsecond, :Nanosecond) ? ["Time"] : period in (:Hour, :Minute, :Second, :Millisecond) ? ["Time", "DateTime"] : ["Date", "DateTime"] - reference = period == :Week ? " For details see [`$accessor_str(::Union{Date, DateTime})`](@ref)." : "" + reference = period === :Week ? " For details see [`$accessor_str(::Union{Date, DateTime})`](@ref)." : "" for typ_str in typs @eval begin @doc """ diff --git a/stdlib/DelimitedFiles/src/DelimitedFiles.jl b/stdlib/DelimitedFiles/src/DelimitedFiles.jl index 857066cbe1cb4..38dffbff17632 100644 --- a/stdlib/DelimitedFiles/src/DelimitedFiles.jl +++ b/stdlib/DelimitedFiles/src/DelimitedFiles.jl @@ -455,7 +455,7 @@ function readdlm_string(sbuff::String, dlm::AbstractChar, T::Type, eol::Abstract dims = dlm_parse(sbuff, eol, dlm, '"', comment_char, ign_empty, quotes, comments, skipstart, skipblanks, offset_handler) break catch ex - if isa(ex, TypeError) && (ex.func == :store_cell) + if isa(ex, TypeError) && (ex.func === :store_cell) T = ex.expected else rethrow() @@ -510,7 +510,7 @@ function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integ end return result(dh) catch ex - isa(ex, TypeError) && (ex.func == :store_cell) && (return dlm_fill(ex.expected, offarr, dims, has_header, sbuff, auto, eol)) + isa(ex, TypeError) && (ex.func === :store_cell) && (return dlm_fill(ex.expected, offarr, dims, has_header, sbuff, auto, eol)) error("at row $row, column $col : $ex") end end @@ -712,7 +712,7 @@ function dlm_parse(dbuff::String, eol::D, dlm::D, qchar::D, cchar::D, end end catch ex - if isa(ex, TypeError) && (ex.func == :store_cell) + if isa(ex, TypeError) && (ex.func === :store_cell) rethrow() else error("at row $(nrows+1), column $col : $ex)") diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index 47b2fc2f3a082..ac1651b06127a 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -146,7 +146,7 @@ end function check_worker_state(w::Worker) if w.state == W_CREATED if !isclusterlazy() - if PGRP.topology == :all_to_all + if PGRP.topology === :all_to_all # Since higher pids connect with lower pids, the remote worker # may not have connected to us yet. Wait for some time. wait_for_conn(w) @@ -448,7 +448,7 @@ function addprocs_locked(manager::ClusterManager; kwargs...) params = merge(default_addprocs_params(), AnyDict(kwargs)) topology(Symbol(params[:topology])) - if PGRP.topology != :all_to_all + if PGRP.topology !== :all_to_all params[:lazy] = false end @@ -616,7 +616,7 @@ function create_worker(manager, wconfig) # - On master, receiving a JoinCompleteMsg triggers rr_ntfy_join (signifies that worker setup is complete) join_list = [] - if PGRP.topology == :all_to_all + if PGRP.topology === :all_to_all # need to wait for lower worker pids to have completed connecting, since the numerical value # of pids is relevant to the connection process, i.e., higher pids connect to lower pids and they # require the value of config.connect_at which is set only upon connection completion @@ -627,7 +627,7 @@ function create_worker(manager, wconfig) end end - elseif PGRP.topology == :custom + elseif PGRP.topology === :custom # wait for requested workers to be up before connecting to them. filterfunc(x) = (x.id != 1) && isdefined(x, :config) && (notnothing(x.config.ident) in something(wconfig.connect_idents, [])) @@ -832,7 +832,7 @@ julia> workers() ``` """ function nprocs() - if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy()) + if myid() == 1 || (PGRP.topology === :all_to_all && !isclusterlazy()) n = length(PGRP.workers) # filter out workers in the process of being setup/shutdown. for jw in PGRP.workers @@ -885,7 +885,7 @@ julia> procs() ``` """ function procs() - if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy()) + 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)] else @@ -894,7 +894,7 @@ function procs() end function id_in_procs(id) # faster version of `id in procs()` - if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy()) + 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) return true @@ -1120,7 +1120,7 @@ function deregister_worker(pg, pid) if myid() == 1 && (myrole() === :master) && isdefined(w, :config) # Notify the cluster manager of this workers death manage(w.manager, w.id, w.config, :deregister) - if PGRP.topology != :all_to_all || isclusterlazy() + if PGRP.topology !== :all_to_all || isclusterlazy() for rpid in workers() try remote_do(deregister_worker, rpid, pid) diff --git a/stdlib/Distributed/src/managers.jl b/stdlib/Distributed/src/managers.jl index 62141b1fd1474..1a05f957dca9f 100644 --- a/stdlib/Distributed/src/managers.jl +++ b/stdlib/Distributed/src/managers.jl @@ -226,7 +226,7 @@ end function manage(manager::SSHManager, id::Integer, config::WorkerConfig, op::Symbol) - if op == :interrupt + if op === :interrupt ospid = config.ospid if ospid !== nothing host = notnothing(config.host) @@ -340,7 +340,7 @@ function launch(manager::LocalManager, params::Dict, launched::Array, c::Conditi end function manage(manager::LocalManager, id::Integer, config::WorkerConfig, op::Symbol) - if op == :interrupt + if op === :interrupt kill(config.process, 2) end end diff --git a/stdlib/FileWatching/src/FileWatching.jl b/stdlib/FileWatching/src/FileWatching.jl index 13a8343441f8b..6f316e5a772f0 100644 --- a/stdlib/FileWatching/src/FileWatching.jl +++ b/stdlib/FileWatching/src/FileWatching.jl @@ -620,7 +620,7 @@ function wait(m::FolderMonitor) take!(m.notify) catch ex unpreserve_handle(m) - if ex isa InvalidStateException && ex.state == :closed + if ex isa InvalidStateException && ex.state === :closed rethrow(EOFError()) # `wait(::Channel)` throws the wrong exception end rethrow() diff --git a/stdlib/InteractiveUtils/src/clipboard.jl b/stdlib/InteractiveUtils/src/clipboard.jl index ac95bfeb84ca4..c824e6a090311 100644 --- a/stdlib/InteractiveUtils/src/clipboard.jl +++ b/stdlib/InteractiveUtils/src/clipboard.jl @@ -11,7 +11,7 @@ if Sys.isapple() # with clipboards. Luckily, the `reattach-to-user-namespace` utility # dodges these issues quite nicely, so we automatically utilize it if # it is installed. - if Sys.which("reattach-to-user-namespace") != nothing + if Sys.which("reattach-to-user-namespace") !== nothing pbcopy_cmd = `reattach-to-user-namespace pbcopy` end @@ -23,7 +23,7 @@ if Sys.isapple() pbpaste_cmd = `pbpaste` # See above comment in `clipboard(x)` - if Sys.which("reattach-to-user-namespace") != nothing + if Sys.which("reattach-to-user-namespace") !== nothing pbcopy_cmd = `reattach-to-user-namespace pbpaste` end read(pbpaste_cmd, String) diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index cec5d4e3904e1..6f3032e264b88 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -88,12 +88,12 @@ function _dump_function_linfo(linfo::Core.MethodInstance, world::UInt, native::B strip_ir_metadata::Bool, dump_module::Bool, syntax::Symbol, optimize::Bool, debuginfo::Symbol=:default, params::CodegenParams=CodegenParams()) - if syntax != :att && syntax != :intel + if syntax !== :att && syntax !== :intel throw(ArgumentError("'syntax' must be either :intel or :att")) end - if debuginfo == :default + if debuginfo === :default debuginfo = :source - elseif debuginfo != :source && debuginfo != :none + elseif debuginfo !== :source && debuginfo !== :none throw(ArgumentError("'debuginfo' must be either :source or :none")) end if native diff --git a/stdlib/InteractiveUtils/src/macros.jl b/stdlib/InteractiveUtils/src/macros.jl index 53ca014fdace2..a3a0bd9929c2c 100644 --- a/stdlib/InteractiveUtils/src/macros.jl +++ b/stdlib/InteractiveUtils/src/macros.jl @@ -99,7 +99,7 @@ function gen_call_with_extracted_types_and_kwargs(__module__, fcn, ex0) arg = ex0[end] # Mandatory argument for i in 1:length(ex0)-1 x = ex0[i] - if x isa Expr && x.head == :(=) # Keyword given of the form "foo=bar" + if x isa Expr && x.head === :(=) # Keyword given of the form "foo=bar" push!(kwargs, x.args) else return Expr(:call, :error, "@$fcn expects only one non-keyword argument") diff --git a/stdlib/LibGit2/src/gitcredential.jl b/stdlib/LibGit2/src/gitcredential.jl index a0504b1c3dd85..f01da3a7ab37e 100644 --- a/stdlib/LibGit2/src/gitcredential.jl +++ b/stdlib/LibGit2/src/gitcredential.jl @@ -122,7 +122,7 @@ function Base.read!(io::IO, cred::GitCredential) end elseif key in GIT_CRED_ATTRIBUTES field = getproperty(cred, Symbol(key)) - field !== nothing && Symbol(key) == :password && Base.shred!(field) + field !== nothing && Symbol(key) === :password && Base.shred!(field) setproperty!(cred, Symbol(key), value) elseif !all(isspace, key) @warn "Unknown git credential attribute found: $(repr(key))" diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl index cfbc37672d044..6ffbe67ea2775 100644 --- a/stdlib/LibGit2/src/types.jl +++ b/stdlib/LibGit2/src/types.jl @@ -1021,7 +1021,7 @@ for (typ, owntyp, sup, cname) in [ return obj end end - if isa(owntyp, Expr) && owntyp.args[1] == :Union && owntyp.args[3] == :Nothing + if isa(owntyp, Expr) && owntyp.args[1] === :Union && owntyp.args[3] === :Nothing @eval begin $typ(ptr::Ptr{Cvoid}, fin::Bool=true) = $typ(nothing, ptr, fin) end @@ -1205,7 +1205,7 @@ mutable struct UserPasswordCredential <: AbstractCredential end function Base.setproperty!(cred::UserPasswordCredential, name::Symbol, value) - if name == :pass + if name === :pass field = getfield(cred, name) Base.shred!(field) end @@ -1240,7 +1240,7 @@ mutable struct SSHCredential <: AbstractCredential end function Base.setproperty!(cred::SSHCredential, name::Symbol, value) - if name == :pass + if name === :pass field = getfield(cred, name) Base.shred!(field) end diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index dee9bd21ee0d6..30002837f8398 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -232,9 +232,9 @@ function checksquare(A...) end function char_uplo(uplo::Symbol) - if uplo == :U + if uplo === :U return 'U' - elseif uplo == :L + elseif uplo === :L return 'L' else throw_uplo() @@ -422,7 +422,7 @@ end function versioninfo(io::IO=stdout) - if Base.libblas_name == "libopenblas" || BLAS.vendor() == :openblas || BLAS.vendor() == :openblas64 + if Base.libblas_name == "libopenblas" || BLAS.vendor() === :openblas || BLAS.vendor() === :openblas64 openblas_config = BLAS.openblas_get_config() println(io, "BLAS: libopenblas (", openblas_config, ")") else @@ -434,7 +434,7 @@ end function __init__() try BLAS.check() - if BLAS.vendor() == :mkl + if BLAS.vendor() === :mkl ccall((:MKL_Set_Interface_Layer, Base.libblas_name), Cvoid, (Cint,), USE_BLAS64 ? 1 : 0) end Threads.resize_nthreads!(Abuf) diff --git a/stdlib/LinearAlgebra/src/bidiag.jl b/stdlib/LinearAlgebra/src/bidiag.jl index 8e5d19105f28e..faa32aee15fa6 100644 --- a/stdlib/LinearAlgebra/src/bidiag.jl +++ b/stdlib/LinearAlgebra/src/bidiag.jl @@ -99,7 +99,7 @@ julia> Bidiagonal(A, :L) # contains the main diagonal and first subdiagonal of A ``` """ function Bidiagonal(A::AbstractMatrix, uplo::Symbol) - Bidiagonal(diag(A, 0), diag(A, uplo == :U ? 1 : -1), uplo) + Bidiagonal(diag(A, 0), diag(A, uplo === :U ? 1 : -1), uplo) end Bidiagonal(A::Bidiagonal) = A diff --git a/stdlib/LinearAlgebra/src/blas.jl b/stdlib/LinearAlgebra/src/blas.jl index be1ad686cbc6b..6a7db4bdd4160 100644 --- a/stdlib/LinearAlgebra/src/blas.jl +++ b/stdlib/LinearAlgebra/src/blas.jl @@ -91,7 +91,7 @@ end const _vendor = determine_vendor() vendor() = _vendor -if vendor() == :openblas64 +if vendor() === :openblas64 macro blasfunc(x) return Expr(:quote, Symbol(x, "64_")) end @@ -110,11 +110,11 @@ Set the number of threads the BLAS library should use. """ function set_num_threads(n::Integer) blas = vendor() - if blas == :openblas + if blas === :openblas return ccall((:openblas_set_num_threads, libblas), Cvoid, (Int32,), n) - elseif blas == :openblas64 + elseif blas === :openblas64 return ccall((:openblas_set_num_threads64_, libblas), Cvoid, (Int32,), n) - elseif blas == :mkl + elseif blas === :mkl # MKL may let us set the number of threads in several ways return ccall((:MKL_Set_Num_Threads, libblas), Cvoid, (Cint,), n) end @@ -130,7 +130,7 @@ end const _testmat = [1.0 0.0; 0.0 -1.0] function check() blas = vendor() - if blas == :openblas || blas == :openblas64 + if blas === :openblas || blas === :openblas64 openblas_config = openblas_get_config() openblas64 = occursin(r".*USE64BITINT.*", openblas_config) if Base.USE_BLAS64 != openblas64 @@ -148,7 +148,7 @@ function check() println("Quitting.") exit() end - elseif blas == :mkl + elseif blas === :mkl if Base.USE_BLAS64 ENV["MKL_INTERFACE_LAYER"] = "ILP64" end diff --git a/stdlib/LinearAlgebra/src/bunchkaufman.jl b/stdlib/LinearAlgebra/src/bunchkaufman.jl index acbd57c1f8554..c57dedc66776e 100644 --- a/stdlib/LinearAlgebra/src/bunchkaufman.jl +++ b/stdlib/LinearAlgebra/src/bunchkaufman.jl @@ -284,17 +284,17 @@ julia> F.U*F.D*F.U' - F.P*A*F.P' """ function getproperty(B::BunchKaufman{T}, d::Symbol) where {T<:BlasFloat} n = size(B, 1) - if d == :p + if d === :p return _ipiv2perm_bk(getfield(B, :ipiv), n, getfield(B, :uplo), B.rook) - elseif d == :P + elseif d === :P return Matrix{T}(I, n, n)[:,invperm(B.p)] - elseif d == :L || d == :U || d == :D + elseif d === :L || d === :U || d === :D if getfield(B, :rook) LUD, od = LAPACK.syconvf_rook!(getfield(B, :uplo), 'C', copy(getfield(B, :LD)), getfield(B, :ipiv)) else LUD, od = LAPACK.syconv!(getfield(B, :uplo), copy(getfield(B, :LD)), getfield(B, :ipiv)) end - if d == :D + if d === :D if getfield(B, :uplo) == 'L' odl = od[1:n - 1] return Tridiagonal(odl, diag(LUD), getfield(B, :symmetric) ? odl : conj.(odl)) @@ -302,7 +302,7 @@ function getproperty(B::BunchKaufman{T}, d::Symbol) where {T<:BlasFloat} odu = od[2:n] return Tridiagonal(getfield(B, :symmetric) ? odu : conj.(odu), diag(LUD), odu) end - elseif d == :L + elseif d === :L if getfield(B, :uplo) == 'L' return UnitLowerTriangular(LUD) else diff --git a/stdlib/LinearAlgebra/src/cholesky.jl b/stdlib/LinearAlgebra/src/cholesky.jl index da47cf94f0550..aa7556e757f7c 100644 --- a/stdlib/LinearAlgebra/src/cholesky.jl +++ b/stdlib/LinearAlgebra/src/cholesky.jl @@ -411,11 +411,11 @@ size(C::Union{Cholesky, CholeskyPivoted}, d::Integer) = size(C.factors, d) function getproperty(C::Cholesky, d::Symbol) Cfactors = getfield(C, :factors) Cuplo = getfield(C, :uplo) - if d == :U + if d === :U return UpperTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors')) - elseif d == :L + elseif d === :L return LowerTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors')) - elseif d == :UL + elseif d === :UL return (Cuplo === 'U' ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors)) else return getfield(C, d) @@ -427,13 +427,13 @@ Base.propertynames(F::Cholesky, private::Bool=false) = function getproperty(C::CholeskyPivoted{T}, d::Symbol) where T<:BlasFloat Cfactors = getfield(C, :factors) Cuplo = getfield(C, :uplo) - if d == :U + if d === :U return UpperTriangular(sym_uplo(Cuplo) == d ? Cfactors : copy(Cfactors')) - elseif d == :L + elseif d === :L return LowerTriangular(sym_uplo(Cuplo) == d ? Cfactors : copy(Cfactors')) - elseif d == :p + elseif d === :p return getfield(C, :piv) - elseif d == :P + elseif d === :P n = size(C, 1) P = zeros(T, n, n) for i = 1:n diff --git a/stdlib/LinearAlgebra/src/hessenberg.jl b/stdlib/LinearAlgebra/src/hessenberg.jl index 5f9b2be1d34a2..c64c2f55669cd 100644 --- a/stdlib/LinearAlgebra/src/hessenberg.jl +++ b/stdlib/LinearAlgebra/src/hessenberg.jl @@ -453,7 +453,7 @@ HessenbergQ(F::Hessenberg{<:Any,<:UpperHessenberg,S,W}) where {S,W} = Hessenberg HessenbergQ(F::Hessenberg{<:Any,<:SymTridiagonal,S,W}) where {S,W} = HessenbergQ{eltype(F.factors),S,W,true}(F.uplo, F.factors, F.τ) function getproperty(F::Hessenberg, d::Symbol) - d == :Q && return HessenbergQ(F) + d === :Q && return HessenbergQ(F) return getfield(F, d) end diff --git a/stdlib/LinearAlgebra/src/ldlt.jl b/stdlib/LinearAlgebra/src/ldlt.jl index ae0d020a298b1..de3716948f65d 100644 --- a/stdlib/LinearAlgebra/src/ldlt.jl +++ b/stdlib/LinearAlgebra/src/ldlt.jl @@ -64,13 +64,13 @@ Factorization{T}(F::LDLt) where {T} = LDLt{T}(F) function getproperty(F::LDLt, d::Symbol) Fdata = getfield(F, :data) - if d == :d + if d === :d return Fdata.dv - elseif d == :D + elseif d === :D return Diagonal(Fdata.dv) - elseif d == :L + elseif d === :L return UnitLowerTriangular(Fdata) - elseif d == :Lt + elseif d === :Lt return UnitUpperTriangular(Fdata) else return getfield(F, d) diff --git a/stdlib/LinearAlgebra/src/lq.jl b/stdlib/LinearAlgebra/src/lq.jl index 7b3829023b4ca..8006fc5509765 100644 --- a/stdlib/LinearAlgebra/src/lq.jl +++ b/stdlib/LinearAlgebra/src/lq.jl @@ -124,9 +124,9 @@ Base.copy(F::Adjoint{T,<:LQ{T}}) where {T} = function getproperty(F::LQ, d::Symbol) m, n = size(F) - if d == :L + if d === :L return tril!(getfield(F, :factors)[1:m, 1:min(m,n)]) - elseif d == :Q + elseif d === :Q return LQPackedQ(getfield(F, :factors), getfield(F, :τ)) else return getfield(F, d) diff --git a/stdlib/LinearAlgebra/src/lu.jl b/stdlib/LinearAlgebra/src/lu.jl index 68e0e1f6a7622..af2669855ac91 100644 --- a/stdlib/LinearAlgebra/src/lu.jl +++ b/stdlib/LinearAlgebra/src/lu.jl @@ -304,15 +304,15 @@ end function getproperty(F::LU{T,<:StridedMatrix}, d::Symbol) where T m, n = size(F) - if d == :L + if d === :L L = tril!(getfield(F, :factors)[1:m, 1:min(m,n)]) for i = 1:min(m,n); L[i,i] = one(T); end return L - elseif d == :U + elseif d === :U return triu!(getfield(F, :factors)[1:min(m,n), 1:n]) - elseif d == :p + elseif d === :p return ipiv2perm(getfield(F, :ipiv), m) - elseif d == :P + elseif d === :P return Matrix{T}(I, m, m)[:,invperm(F.p)] else getfield(F, d) @@ -553,7 +553,7 @@ factorize(A::Tridiagonal) = lu(A) function getproperty(F::LU{T,Tridiagonal{T,V}}, d::Symbol) where {T,V} m, n = size(F) - if d == :L + if d === :L dl = getfield(getfield(F, :factors), :dl) L = Array(Bidiagonal(fill!(similar(dl, n), one(T)), dl, d)) for i = 2:n @@ -562,15 +562,15 @@ function getproperty(F::LU{T,Tridiagonal{T,V}}, d::Symbol) where {T,V} L[i, 1:i - 1] = tmp end return L - elseif d == :U + elseif d === :U U = Array(Bidiagonal(getfield(getfield(F, :factors), :d), getfield(getfield(F, :factors), :du), d)) for i = 1:n - 2 U[i,i + 2] = getfield(getfield(F, :factors), :du2)[i] end return U - elseif d == :p + elseif d === :p return ipiv2perm(getfield(F, :ipiv), m) - elseif d == :P + elseif d === :P return Matrix{T}(I, m, m)[:,invperm(F.p)] end return getfield(F, d) diff --git a/stdlib/LinearAlgebra/src/qr.jl b/stdlib/LinearAlgebra/src/qr.jl index 48949aa393284..15c6bf2d5bc0a 100644 --- a/stdlib/LinearAlgebra/src/qr.jl +++ b/stdlib/LinearAlgebra/src/qr.jl @@ -421,9 +421,9 @@ end function getproperty(F::QR, d::Symbol) m, n = size(F) - if d == :R + if d === :R return triu!(getfield(F, :factors)[1:min(m,n), 1:n]) - elseif d == :Q + elseif d === :Q return QRPackedQ(getfield(F, :factors), F.τ) else getfield(F, d) @@ -431,9 +431,9 @@ function getproperty(F::QR, d::Symbol) end function getproperty(F::QRCompactWY, d::Symbol) m, n = size(F) - if d == :R + if d === :R return triu!(getfield(F, :factors)[1:min(m,n), 1:n]) - elseif d == :Q + elseif d === :Q return QRCompactWYQ(getfield(F, :factors), F.T) else getfield(F, d) @@ -444,13 +444,13 @@ Base.propertynames(F::Union{QR,QRCompactWY}, private::Bool=false) = function getproperty(F::QRPivoted{T}, d::Symbol) where T m, n = size(F) - if d == :R + if d === :R return triu!(getfield(F, :factors)[1:min(m,n), 1:n]) - elseif d == :Q + elseif d === :Q return QRPackedQ(getfield(F, :factors), F.τ) - elseif d == :p + elseif d === :p return getfield(F, :jpvt) - elseif d == :P + elseif d === :P p = F.p n = length(p) P = zeros(T, n, n) diff --git a/stdlib/LinearAlgebra/src/schur.jl b/stdlib/LinearAlgebra/src/schur.jl index 9457f71b415af..9ea03b0bf12a3 100644 --- a/stdlib/LinearAlgebra/src/schur.jl +++ b/stdlib/LinearAlgebra/src/schur.jl @@ -149,9 +149,9 @@ schur(A::LowerTriangular) = schur(copyto!(similar(parent(A)), A)) schur(A::Tridiagonal) = schur(Matrix(A)) function getproperty(F::Schur, d::Symbol) - if d == :Schur + if d === :Schur return getfield(F, :T) - elseif d == :vectors + elseif d === :vectors return getfield(F, :Z) else getfield(F, d) @@ -305,15 +305,15 @@ ordschur(gschur::GeneralizedSchur, select::Union{Vector{Bool},BitVector}) = GeneralizedSchur(_ordschur(gschur.S, gschur.T, gschur.Q, gschur.Z, select)...) function getproperty(F::GeneralizedSchur, d::Symbol) - if d == :values + if d === :values return getfield(F, :α) ./ getfield(F, :β) - elseif d == :alpha + elseif d === :alpha return getfield(F, :α) - elseif d == :beta + elseif d === :beta return getfield(F, :β) - elseif d == :left + elseif d === :left return getfield(F, :Q) - elseif d == :right + elseif d === :right return getfield(F, :Z) else getfield(F, d) diff --git a/stdlib/LinearAlgebra/src/svd.jl b/stdlib/LinearAlgebra/src/svd.jl index 69cd6aa551c00..843235a615d3b 100644 --- a/stdlib/LinearAlgebra/src/svd.jl +++ b/stdlib/LinearAlgebra/src/svd.jl @@ -202,7 +202,7 @@ function svd(A::Transpose; full::Bool = false, alg::Algorithm = default_svd_alg( end function getproperty(F::SVD, d::Symbol) - if d == :V + if d === :V return getfield(F, :Vt)' else return getfield(F, d) @@ -526,13 +526,13 @@ svd(x::Number, y::Number) = svd(fill(x, 1, 1), fill(y, 1, 1)) FV = getfield(F, :V) FQ = getfield(F, :Q) FR = getfield(F, :R) - if d == :alpha + if d === :alpha return Fa - elseif d == :beta + elseif d === :beta return Fb - elseif d == :vals || d == :S + elseif d === :vals || d === :S return Fa[1:Fk + Fl] ./ Fb[1:Fk + Fl] - elseif d == :D1 + elseif d === :D1 m = size(FU, 1) if m - Fk - Fl >= 0 return [Matrix{T}(I, Fk, Fk) zeros(T, Fk, Fl) ; @@ -541,7 +541,7 @@ svd(x::Number, y::Number) = svd(fill(x, 1, 1), fill(y, 1, 1)) else return [Matrix{T}(I, m, Fk) [zeros(T, Fk, m - Fk); Diagonal(Fa[Fk + 1:m])] zeros(T, m, Fk + Fl - m)] end - elseif d == :D2 + elseif d === :D2 m = size(FU, 1) p = size(FV, 1) if m - Fk - Fl >= 0 @@ -549,7 +549,7 @@ svd(x::Number, y::Number) = svd(fill(x, 1, 1), fill(y, 1, 1)) else return [zeros(T, p, Fk) [Diagonal(Fb[Fk + 1:m]); zeros(T, Fk + p - m, m - Fk)] [zeros(T, m - Fk, Fk + Fl - m); Matrix{T}(I, Fk + p - m, Fk + Fl - m)]] end - elseif d == :R0 + elseif d === :R0 n = size(FQ, 1) return [zeros(T, Fk + Fl, n - Fk - Fl) FR] else diff --git a/stdlib/Markdown/src/GitHub/table.jl b/stdlib/Markdown/src/GitHub/table.jl index b8652e00121e4..8e835ac59fc13 100644 --- a/stdlib/Markdown/src/GitHub/table.jl +++ b/stdlib/Markdown/src/GitHub/table.jl @@ -81,9 +81,9 @@ colwidths(rows; len = length, min = 0) = reduce((x,y) -> max.(x,y), [min; convert(Vector{Vector{Int}}, mapmap(len, rows))]) padding(width, twidth, a) = - a == :l ? (0, twidth - width) : - a == :r ? (twidth - width, 0) : - a == :c ? (floor(Int, (twidth-width)/2), ceil(Int, (twidth-width)/2)) : + a === :l ? (0, twidth - width) : + a === :r ? (twidth - width, 0) : + a === :c ? (floor(Int, (twidth-width)/2), ceil(Int, (twidth-width)/2)) : error("Invalid alignment $a") function padcells!(rows, align; len = length, min = 0) @@ -97,9 +97,9 @@ function padcells!(rows, align; len = length, min = 0) end _dash(width, align) = - align == :l ? ":" * "-"^width * " " : - align == :r ? " " * "-"^width * ":" : - align == :c ? ":" * "-"^width * ":" : + align === :l ? ":" * "-"^width * " " : + align === :r ? " " * "-"^width * ":" : + align === :c ? ":" * "-"^width * ":" : throw(ArgumentError("Invalid alignment $align")) function plain(io::IO, md::Table) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 810610d653e72..46d70508d273b 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -1183,7 +1183,7 @@ end ### external printf interface ### is_str_expr(ex) = - isa(ex,Expr) && (ex.head == :string || (ex.head == :macrocall && isa(ex.args[1],Symbol) && + isa(ex,Expr) && (ex.head === :string || (ex.head === :macrocall && isa(ex.args[1],Symbol) && endswith(string(ex.args[1]),"str"))) function _printf(macroname, io, fmt, args) @@ -1192,7 +1192,7 @@ function _printf(macroname, io, fmt, args) has_splatting = false for arg in args - if isa(arg, Expr) && arg.head == :... + if isa(arg, Expr) && arg.head === :... has_splatting = true break end diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 429bb80fe4f60..057bb4d287a40 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -444,9 +444,9 @@ function print_flat(io::IO, lilist::Vector{StackFrame}, n::Vector{Int}, m::Vector{Int}, cols::Int, filenamemap::Dict{Symbol,String}, fmt::ProfileFormat) - if fmt.sortedby == :count + if fmt.sortedby === :count p = sortperm(n) - elseif fmt.sortedby == :overhead + elseif fmt.sortedby === :overhead p = sortperm(m) else p = liperm(lilist) @@ -634,7 +634,7 @@ function tree!(root::StackFrameTree{T}, all::Vector{UInt64}, lidict::Union{LineI startframe = i else pushfirst!(build, parent) - if recur === :flat || recur == :flatc + if recur === :flat || recur === :flatc # Rewind the `parent` tree back, if this exact ip was already present *higher* in the current tree found = false for j in 1:(startframe - i) @@ -745,13 +745,13 @@ function print_tree(io::IO, bt::StackFrameTree{T}, cols::Int, fmt::ProfileFormat # Generate the string for each line strs = tree_format(nexts, level, cols, maxes, filenamemap, T === UInt64) # Recurse to the next level - if fmt.sortedby == :count + if fmt.sortedby === :count counts = collect(frame.count for frame in nexts) p = sortperm(counts) - elseif fmt.sortedby == :overhead + elseif fmt.sortedby === :overhead m = collect(frame.overhead for frame in nexts) p = sortperm(m) - elseif fmt.sortedby == :flat_count + elseif fmt.sortedby === :flat_count m = collect(frame.flat_count for frame in nexts) p = sortperm(m) else diff --git a/stdlib/REPL/src/LineEdit.jl b/stdlib/REPL/src/LineEdit.jl index 0a71488859819..ee2c802c61e6f 100644 --- a/stdlib/REPL/src/LineEdit.jl +++ b/stdlib/REPL/src/LineEdit.jl @@ -242,19 +242,19 @@ end function set_action!(s::MIState, command::Symbol) # if a command is already running, don't update the current_action field, # as the caller is used as a helper function - s.current_action == :unknown || return + s.current_action === :unknown || return ## handle activeness of the region is_shift_move(cmd) = startswith(String(cmd), "shift_") if is_shift_move(command) - if region_active(s) != :shift + if region_active(s) !== :shift setmark(s, false) activate_region(s, :shift) # NOTE: if the region was already active from a non-shift # move (e.g. ^Space^Space), the region is visibly changed end elseif !(preserve_active(command) || - command_group(command) == :movement && region_active(s) == :mark) + command_group(command) === :movement && region_active(s) === :mark) # if we move after a shift-move, the region is de-activated # (e.g. like emacs behavior) deactivate_region(s) @@ -647,7 +647,7 @@ function edit_move_down(s) end function edit_shift_move(s::MIState, move_function::Function) - @assert command_group(move_function) == :movement + @assert command_group(move_function) === :movement set_action!(s, Symbol(:shift_, move_function)) return move_function(s) end @@ -999,7 +999,7 @@ function edit_transpose_words(buf::IOBuffer, mode=:emacs) mode in [:readline, :emacs] || throw(ArgumentError("`mode` must be `:readline` or `:emacs`")) pos = position(buf) - if mode == :emacs + if mode === :emacs char_move_word_left(buf) char_move_word_right(buf) end @@ -2013,7 +2013,7 @@ end function edit_abort(s, confirm::Bool=options(s).confirm_exit; key="^D") set_action!(s, :edit_abort) - if !confirm || s.last_action == :edit_abort + if !confirm || s.last_action === :edit_abort println(terminal(s)) return :abort else @@ -2403,7 +2403,7 @@ function prompt!(term::TextTerminal, prompt::ModalInterface, s::MIState = init_s transition(s, old_state) status = :done end - status != :ignore && (s.last_action = s.current_action) + status !== :ignore && (s.last_action = s.current_action) if status === :abort return buffer(s), false, false elseif status === :done diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index a20b4d027c4b4..92cba45589e14 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -243,7 +243,7 @@ function run_frontend(repl::BasicREPL, backend::REPLBackendRef) end end ast = Base.parse_input_line(line) - (isa(ast,Expr) && ast.head == :incomplete) || break + (isa(ast,Expr) && ast.head === :incomplete) || break end if !isempty(line) response = eval_with_backend(ast, backend) @@ -955,7 +955,7 @@ function setup_interface( end end ast, pos = Meta.parse(input, oldpos, raise=false, depwarn=false) - if (isa(ast, Expr) && (ast.head == :error || ast.head == :incomplete)) || + if (isa(ast, Expr) && (ast.head === :error || ast.head === :incomplete)) || (pos > ncodeunits(input) && !endswith(input, '\n')) # remaining text is incomplete (an error, or parser ran to the end but didn't stop with a newline): # Insert all the remaining text as one line (might be empty) diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index 442ffda3edc65..6b15996b51d97 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -337,7 +337,7 @@ end # will show it consist of Expr, QuoteNode's and Symbol's which all needs to # be handled differently to iterate down to get the value of whitespace_chars. function get_value(sym::Expr, fn) - sym.head != :. && return (nothing, false) + sym.head !== :. && return (nothing, false) for ex in sym.args fn, found = get_value(ex, fn) !found && return (nothing, false) @@ -552,12 +552,12 @@ function project_deps_get_completion_candidates(pkgstarts::String, project_file: for line in eachline(io) if occursin(Base.re_section, line) state = occursin(Base.re_section_deps, line) ? :deps : :other - elseif state == :top + elseif state === :top if (m = match(Base.re_name_to_string, line)) !== nothing root_name = String(m.captures[1]) startswith(root_name, pkgstarts) && push!(loading_candidates, root_name) end - elseif state == :deps + elseif state === :deps if (m = match(Base.re_key_to_string, line)) !== nothing dep_name = m.captures[1] startswith(dep_name, pkgstarts) && push!(loading_candidates, dep_name) @@ -592,7 +592,7 @@ function completions(string, pos, context_module=Main)::Completions paths, r, success = complete_path(replace(string[r], r"\\ " => " "), pos) - if inc_tag == :string && + if inc_tag === :string && length(paths) == 1 && # Only close if there's a single choice, !isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # except if it's a directory @@ -610,7 +610,7 @@ function completions(string, pos, context_module=Main)::Completions # Make sure that only bslash_completions is working on strings inc_tag==:string && return String[], 0:-1, false - if inc_tag == :other && should_method_complete(partial) + if inc_tag === :other && should_method_complete(partial) frange, method_name_end = find_start_brace(partial) ex = Meta.parse(partial[frange] * ")", raise=false, depwarn=false) @@ -621,7 +621,7 @@ function completions(string, pos, context_module=Main)::Completions return complete_methods(ex, context_module), first(frange):(method_name_end - 1), false end end - elseif inc_tag == :comment + elseif inc_tag === :comment return Completion[], 0:-1, false end diff --git a/stdlib/REPL/src/TerminalMenus/config.jl b/stdlib/REPL/src/TerminalMenus/config.jl index ce2cd3b88bf60..d84a14aac7595 100644 --- a/stdlib/REPL/src/TerminalMenus/config.jl +++ b/stdlib/REPL/src/TerminalMenus/config.jl @@ -29,26 +29,26 @@ function config(;charset::Symbol = :na, supress_output::Union{Nothing, Bool}=nothing, ctrl_c_interrupt::Union{Nothing, Bool}=nothing) - if charset == :ascii + if charset === :ascii cursor = '>' up_arrow = '^' down_arrow = 'v' checked = "[X]" unchecked = "[ ]" - elseif charset == :unicode + elseif charset === :unicode cursor = '→' up_arrow = '↑' down_arrow = '↓' checked = "✓" unchecked = "⬚" - elseif charset == :na + elseif charset === :na else throw(ArgumentError("charset should be :ascii or :unicode, received $charset")) end scroll ∉ [:na, :wrap, :nowrap] && throw(ArgumentError("scroll must be :wrap or :nowrap, received $scroll")) - scroll == :wrap && (CONFIG[:scroll_wrap] = true) - scroll == :nowrap && (CONFIG[:scroll_wrap] = false) + scroll === :wrap && (CONFIG[:scroll_wrap] = true) + scroll === :nowrap && (CONFIG[:scroll_wrap] = false) cursor != '\0' && (CONFIG[:cursor] = cursor) up_arrow != '\0' && (CONFIG[:up_arrow] = up_arrow) diff --git a/stdlib/REPL/src/Terminals.jl b/stdlib/REPL/src/Terminals.jl index f0e03c0a23e40..c8135bb6f2879 100644 --- a/stdlib/REPL/src/Terminals.jl +++ b/stdlib/REPL/src/Terminals.jl @@ -158,7 +158,7 @@ else function hascolor(t::TTYTerminal) startswith(t.term_type, "xterm") && return true try - @static if Sys.KERNEL == :FreeBSD + @static if Sys.KERNEL === :FreeBSD return success(`tput AF 0`) else return success(`tput setaf 0`) diff --git a/stdlib/SharedArrays/src/SharedArrays.jl b/stdlib/SharedArrays/src/SharedArrays.jl index 91c555dc6757f..c80a74e617227 100644 --- a/stdlib/SharedArrays/src/SharedArrays.jl +++ b/stdlib/SharedArrays/src/SharedArrays.jl @@ -454,7 +454,7 @@ function serialize(s::AbstractSerializer, S::SharedArray) for n in fieldnames(SharedArray) if n in [:s, :pidx, :loc_subarr_1d] writetag(s.io, UNDEFREF_TAG) - elseif n == :refs + elseif n === :refs v = getfield(S, n) if isa(v[1], Future) # convert to ids to avoid distributed GC overhead @@ -612,9 +612,9 @@ function print_shmem_limits(slen) pfx = "kernel" elseif Sys.isapple() pfx = "kern.sysv" - elseif Sys.KERNEL == :FreeBSD || Sys.KERNEL == :DragonFly + elseif Sys.KERNEL === :FreeBSD || Sys.KERNEL === :DragonFly pfx = "kern.ipc" - elseif Sys.KERNEL == :OpenBSD + elseif Sys.KERNEL === :OpenBSD pfx = "kern.shminfo" else # seems NetBSD does not have *.shmall diff --git a/stdlib/SparseArrays/src/sparsematrix.jl b/stdlib/SparseArrays/src/sparsematrix.jl index 8334b9e8d70df..8620159846e63 100644 --- a/stdlib/SparseArrays/src/sparsematrix.jl +++ b/stdlib/SparseArrays/src/sparsematrix.jl @@ -3510,7 +3510,7 @@ end # sortSparseMatrixCSC!(A, sortindices = :sortcols) # Sort each column with sort() # sortSparseMatrixCSC!(A, sortindices = :doubletranspose) # Sort with a double transpose function sortSparseMatrixCSC!(A::AbstractSparseMatrixCSC{Tv,Ti}; sortindices::Symbol = :sortcols) where {Tv,Ti} - if sortindices == :doubletranspose + if sortindices === :doubletranspose nB, mB = size(A) B = SparseMatrixCSC(mB, nB, Vector{Ti}(undef, nB+1), similar(rowvals(A)), similar(nonzeros(A))) transpose!(B, A) diff --git a/stdlib/SparseArrays/src/sparsevector.jl b/stdlib/SparseArrays/src/sparsevector.jl index c9f718147bca1..c072943bd9141 100644 --- a/stdlib/SparseArrays/src/sparsevector.jl +++ b/stdlib/SparseArrays/src/sparsevector.jl @@ -1334,7 +1334,7 @@ end for f in [:sum, :maximum, :minimum], op in [:abs, :abs2] SV = :AbstractSparseVector - if f == :minimum + if f === :minimum @eval ($f)(::typeof($op), x::$SV{T}) where {T<:Number} = nnz(x) < length(x) ? ($op)(zero(T)) : ($f)($op, nonzeros(x)) else @eval ($f)(::typeof($op), x::$SV) = ($f)($op, nonzeros(x)) diff --git a/stdlib/SuiteSparse/src/cholmod.jl b/stdlib/SuiteSparse/src/cholmod.jl index 44ebb7179e830..f808716ed0b5b 100644 --- a/stdlib/SuiteSparse/src/cholmod.jl +++ b/stdlib/SuiteSparse/src/cholmod.jl @@ -375,12 +375,12 @@ mutable struct FactorComponent{Tv,S} <: AbstractMatrix{Tv} function FactorComponent{Tv,S}(F::Factor{Tv}) where {Tv,S} s = unsafe_load(pointer(F)) if s.is_ll != 0 - if !(S == :L || S == :U || S == :PtL || S == :UP) + if !(S === :L || S === :U || S === :PtL || S === :UP) throw(CHOLMODException(string(S, " not supported for sparse ", "LLt matrices; try :L, :U, :PtL, or :UP"))) end - elseif !(S == :L || S == :U || S == :PtL || S == :UP || - S == :D || S == :LD || S == :DU || S == :PtLD || S == :DUP) + elseif !(S === :L || S === :U || S === :PtL || S === :UP || + S === :D || S === :LD || S === :DU || S === :PtLD || S === :DUP) throw(CHOLMODException(string(S, " not supported for sparse LDLt ", "matrices; try :L, :U, :PtL, :UP, :D, :LD, :DU, :PtLD, or :DUP"))) end @@ -1182,9 +1182,9 @@ function getindex(A::Sparse{T}, i0::Integer, i1::Integer) where T end @inline function getproperty(F::Factor, sym::Symbol) - if sym == :p + if sym === :p return get_perm(F) - elseif sym == :ptr + elseif sym === :ptr return getfield(F, :ptr) else return FactorComponent(F, sym) diff --git a/stdlib/SuiteSparse/src/spqr.jl b/stdlib/SuiteSparse/src/spqr.jl index 88a4522520fd8..6e734417a1b6a 100644 --- a/stdlib/SuiteSparse/src/spqr.jl +++ b/stdlib/SuiteSparse/src/spqr.jl @@ -312,11 +312,11 @@ julia> F.pcol ``` """ @inline function Base.getproperty(F::QRSparse, d::Symbol) - if d == :Q + if d === :Q return QRSparseQ(F.factors, F.τ, size(F, 2)) - elseif d == :prow + elseif d === :prow return invperm(F.rpivinv) - elseif d == :pcol + elseif d === :pcol return F.cpiv else getfield(F, d) diff --git a/stdlib/SuiteSparse/src/umfpack.jl b/stdlib/SuiteSparse/src/umfpack.jl index 155cbe2ab53ef..7a7a94f2dc61d 100644 --- a/stdlib/SuiteSparse/src/umfpack.jl +++ b/stdlib/SuiteSparse/src/umfpack.jl @@ -214,7 +214,7 @@ end ## Wrappers for UMFPACK functions # generate the name of the C function according to the value and integer types -umf_nm(nm,Tv,Ti) = "umfpack_" * (Tv == :Float64 ? "d" : "z") * (Ti == :Int64 ? "l_" : "i_") * nm +umf_nm(nm,Tv,Ti) = "umfpack_" * (Tv === :Float64 ? "d" : "z") * (Ti === :Int64 ? "l_" : "i_") * nm for itype in UmfpackIndexTypes sym_r = umf_nm("symbolic", :Float64, itype) @@ -487,20 +487,20 @@ end @inline function getproperty(lu::UmfpackLU, d::Symbol) - if d == :L || d == :U || d == :p || d == :q || d == :Rs || d == :(:) + if d === :L || d === :U || d === :p || d === :q || d === :Rs || d === :(:) # Guard the call to umf_extract behaind a branch to avoid infinite recursion L, U, p, q, Rs = umf_extract(lu) - if d == :L + if d === :L return L - elseif d == :U + elseif d === :U return U - elseif d == :p + elseif d === :p return p - elseif d == :q + elseif d === :q return q - elseif d == :Rs + elseif d === :Rs return Rs - elseif d == :(:) + elseif d === :(:) return (L, U, p, q, Rs) end else diff --git a/stdlib/Test/src/Test.jl b/stdlib/Test/src/Test.jl index f14faa5b05814..d3d6892b608d1 100644 --- a/stdlib/Test/src/Test.jl +++ b/stdlib/Test/src/Test.jl @@ -92,10 +92,10 @@ function Base.show(io::IO, t::Pass) if !(t.orig_expr === nothing) print(io, "\n Expression: ", t.orig_expr) end - if t.test_type == :test_throws + if t.test_type === :test_throws # The correct type of exception was thrown print(io, "\n Thrown: ", typeof(t.value)) - elseif t.test_type == :test && t.data !== nothing + elseif t.test_type === :test && t.data !== nothing # The test was an expression, so display the term-by-term # evaluated version as well print(io, "\n Evaluated: ", t.data) @@ -120,15 +120,15 @@ function Base.show(io::IO, t::Fail) print(io, " at ") printstyled(io, something(t.source.file, :none), ":", t.source.line, "\n"; bold=true, color=:default) print(io, " Expression: ", t.orig_expr) - if t.test_type == :test_throws_wrong + if t.test_type === :test_throws_wrong # An exception was thrown, but it was of the wrong type print(io, "\n Expected: ", t.data) print(io, "\n Thrown: ", isa(t.data, Type) ? typeof(t.value) : t.value) - elseif t.test_type == :test_throws_nothing + elseif t.test_type === :test_throws_nothing # An exception was expected, but no exception was thrown print(io, "\n Expected: ", t.data) print(io, "\n No exception thrown") - elseif t.test_type == :test && t.data !== nothing + elseif t.test_type === :test && t.data !== nothing # The test was an expression, so display the term-by-term # evaluated version as well print(io, "\n Evaluated: ", t.data) @@ -167,28 +167,28 @@ mutable struct Error <: Result end end function Base.show(io::IO, t::Error) - if t.test_type == :test_interrupted + if t.test_type === :test_interrupted printstyled(io, "Interrupted", color=Base.error_color()) return end printstyled(io, "Error During Test"; bold=true, color=Base.error_color()) print(io, " at ") printstyled(io, something(t.source.file, :none), ":", t.source.line, "\n"; bold=true, color=:default) - if t.test_type == :test_nonbool + if t.test_type === :test_nonbool println(io, " Expression evaluated to non-Boolean") println(io, " Expression: ", t.orig_expr) print( io, " Value: ", t.value) - elseif t.test_type == :test_error + elseif t.test_type === :test_error println(io, " Test threw exception") println(io, " Expression: ", t.orig_expr) # Capture error message and indent to match join(io, (" " * line for line in split(t.backtrace, "\n")), "\n") - elseif t.test_type == :test_unbroken + elseif t.test_type === :test_unbroken # A test that was expected to fail did not println(io, " Unexpected Pass") println(io, " Expression: ", t.orig_expr) println(io, " Got correct result, please change to @test if no longer broken.") - elseif t.test_type == :nontest_error + elseif t.test_type === :nontest_error # we had an error outside of a @test println(io, " Got exception outside of a @test") # Capture error message and indent to match @@ -208,7 +208,7 @@ mutable struct Broken <: Result end function Base.show(io::IO, t::Broken) printstyled(io, "Test Broken\n"; bold=true, color=Base.warn_color()) - if t.test_type == :skipped && !(t.orig_expr === nothing) + if t.test_type === :skipped && !(t.orig_expr === nothing) print(io, " Skipped: ", t.orig_expr) elseif !(t.orig_expr === nothing) print(io, " Expression: ", t.orig_expr) @@ -238,7 +238,7 @@ function eval_test(evaluated::Expr, quoted::Expr, source::LineNumberNode, negate quoted_args = quoted.args n = length(evaled_args) kw_suffix = "" - if evaluated.head == :comparison + if evaluated.head === :comparison args = evaled_args while i < n a, op, b = args[i], args[i+1], args[i+2] @@ -250,7 +250,7 @@ function eval_test(evaluated::Expr, quoted::Expr, source::LineNumberNode, negate i += 2 end - elseif evaluated.head == :call + elseif evaluated.head === :call op = evaled_args[1] kwargs = evaled_args[2].args # Keyword arguments from `Expr(:parameters, ...)` args = evaled_args[3:n] @@ -295,9 +295,9 @@ so that e.g. `@test a ≈ b atol=ε` means `@test ≈(a, b, atol=ε)`. test_expr!(m, ex) = ex function test_expr!(m, ex, kws...) - ex isa Expr && ex.head == :call || @goto fail + ex isa Expr && ex.head === :call || @goto fail for kw in kws - kw isa Expr && kw.head == :(=) || @goto fail + kw isa Expr && kw.head === :(=) || @goto fail kw.head = :kw push!(ex.args, kw) end @@ -411,18 +411,18 @@ function get_test_result(ex, source) negate = QuoteNode(false) orig_ex = ex # Evaluate `not` wrapped functions separately for pretty-printing failures - if isa(ex, Expr) && ex.head == :call && length(ex.args) == 2 && ex.args[1] === :! + if isa(ex, Expr) && ex.head === :call && length(ex.args) == 2 && ex.args[1] === :! negate = QuoteNode(true) ex = ex.args[2] end # Normalize non-dot comparison operator calls to :comparison expressions - is_splat = x -> isa(x, Expr) && x.head == :... - if isa(ex, Expr) && ex.head == :call && length(ex.args) == 3 && + is_splat = x -> isa(x, Expr) && x.head === :... + if isa(ex, Expr) && ex.head === :call && length(ex.args) == 3 && first(string(ex.args[1])) != '.' && !is_splat(ex.args[2]) && !is_splat(ex.args[3]) && (ex.args[1] === :(==) || Base.operator_precedence(ex.args[1]) == comparison_prec) ex = Expr(:comparison, ex.args[2], ex.args[1], ex.args[3]) end - if isa(ex, Expr) && ex.head == :comparison + if isa(ex, Expr) && ex.head === :comparison # pass all terms of the comparison to `eval_comparison`, as an Expr escaped_terms = [esc(arg) for arg in ex.args] quoted_terms = [QuoteNode(arg) for arg in ex.args] @@ -432,7 +432,7 @@ function get_test_result(ex, source) $(QuoteNode(source)), $negate, )) - elseif isa(ex, Expr) && ex.head == :call && ex.args[1] in DISPLAY_FAILED + elseif isa(ex, Expr) && ex.head === :call && ex.args[1] in DISPLAY_FAILED escaped_func = esc(ex.args[1]) quoted_func = QuoteNode(ex.args[1]) @@ -442,18 +442,18 @@ function get_test_result(ex, source) # Keywords that occur before `;`. Note that the keywords are being revised into # a form we can splat. for a in ex.args[2:end] - if isa(a, Expr) && a.head == :kw + if isa(a, Expr) && a.head === :kw push!(escaped_kwargs, Expr(:call, :(=>), QuoteNode(a.args[1]), esc(a.args[2]))) end end # Keywords that occur after ';' parameters_expr = ex.args[2] - if isa(parameters_expr, Expr) && parameters_expr.head == :parameters + if isa(parameters_expr, Expr) && parameters_expr.head === :parameters for a in parameters_expr.args - if isa(a, Expr) && a.head == :kw + if isa(a, Expr) && a.head === :kw push!(escaped_kwargs, Expr(:call, :(=>), QuoteNode(a.args[1]), esc(a.args[2]))) - elseif isa(a, Expr) && a.head == :... + elseif isa(a, Expr) && a.head === :... push!(escaped_kwargs, Expr(:..., esc(a.args[1]))) end end @@ -463,7 +463,7 @@ function get_test_result(ex, source) for a in ex.args[2:end] isa(a, Expr) && a.head in (:kw, :parameters) && continue - if isa(a, Expr) && a.head == :... + if isa(a, Expr) && a.head === :... push!(escaped_args, Expr(:..., esc(a.args[1]))) else push!(escaped_args, esc(a)) @@ -761,7 +761,7 @@ function record(ts::DefaultTestSet, t::Union{Fail, Error}) if myid() == 1 printstyled(ts.description, ": ", color=:white) # don't print for interrupted tests - if !(t isa Error) || t.test_type != :test_interrupted + if !(t isa Error) || t.test_type !== :test_interrupted print(t) # don't print the backtrace for Errors because it gets printed in the show # method @@ -1063,11 +1063,11 @@ macro testset(args...) tests = args[end] # Determine if a single block or for-loop style - if !isa(tests,Expr) || (tests.head != :for && tests.head != :block) + if !isa(tests,Expr) || (tests.head !== :for && tests.head !== :block) error("Expected begin/end block or for loop as argument to @testset") end - if tests.head == :for + if tests.head === :for return testset_forloop(args, tests, __source__) else return testset_beginend(args, tests, __source__) @@ -1135,9 +1135,9 @@ function testset_forloop(args, testloop, source) # description and we'll definitely need them for generating the # comprehension expression at the end loopvars = Expr[] - if testloop.args[1].head == :(=) + if testloop.args[1].head === :(=) push!(loopvars, testloop.args[1]) - elseif testloop.args[1].head == :block + elseif testloop.args[1].head === :block for loopvar in testloop.args[1].args push!(loopvars, loopvar) end @@ -1224,10 +1224,10 @@ function parse_testset_args(args) if isa(arg, Symbol) testsettype = esc(arg) # a string is the description - elseif isa(arg, AbstractString) || (isa(arg, Expr) && arg.head == :string) + elseif isa(arg, AbstractString) || (isa(arg, Expr) && arg.head === :string) desc = esc(arg) # an assignment is an option - elseif isa(arg, Expr) && arg.head == :(=) + elseif isa(arg, Expr) && arg.head === :(=) # we're building up a Dict literal here key = Expr(:quote, arg.args[1]) push!(options.args, Expr(:call, :(=>), key, arg.args[2])) diff --git a/stdlib/Test/src/logging.jl b/stdlib/Test/src/logging.jl index 66032cdc8f83b..d8d088f875361 100644 --- a/stdlib/Test/src/logging.jl +++ b/stdlib/Test/src/logging.jl @@ -147,7 +147,7 @@ macro test_logs(exs...) patterns = Any[] kwargs = Any[] for e in exs[1:end-1] - if e isa Expr && e.head == :(=) + if e isa Expr && e.head === :(=) push!(kwargs, esc(Expr(:kw, e.args...))) else push!(patterns, esc(e)) @@ -179,10 +179,10 @@ end function match_logs(f, patterns...; match_mode::Symbol=:all, kwargs...) logs,value = collect_test_logs(f; kwargs...) - if match_mode == :all + if match_mode === :all didmatch = length(logs) == length(patterns) && all(occursin(p, l) for (p,l) in zip(patterns, logs)) - elseif match_mode == :any + elseif match_mode === :any didmatch = all(any(occursin(p, l) for l in logs) for p in patterns) end didmatch,logs,value @@ -190,12 +190,12 @@ end # TODO: Use a version of parse_level from stdlib/Logging, when it exists. function parse_level(level::Symbol) - if level == :belowminlevel return Logging.BelowMinLevel - elseif level == :debug return Logging.Debug - elseif level == :info return Logging.Info - elseif level == :warn return Logging.Warn - elseif level == :error return Logging.Error - elseif level == :abovemaxlevel return Logging.AboveMaxLevel + if level === :belowminlevel return Logging.BelowMinLevel + elseif level === :debug return Logging.Debug + elseif level === :info return Logging.Info + elseif level === :warn return Logging.Warn + elseif level === :error return Logging.Error + elseif level === :abovemaxlevel return Logging.AboveMaxLevel else throw(ArgumentError("Unknown log level $level")) end