Skip to content

Commit

Permalink
fully normalize x == ::Symbol to x === ::Symbol (JuliaLang#45944)
Browse files Browse the repository at this point in the history
It would be better to use a consistent style in our code base.
The changes are big, but all merely cosmetic changes made
half-automatically with a find-and-replace.
  • Loading branch information
aviatesk committed Jul 6, 2022
1 parent 301b62a commit dd19c5a
Show file tree
Hide file tree
Showing 54 changed files with 152 additions and 152 deletions.
4 changes: 2 additions & 2 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ function getfield_nothrow(@nospecialize(s00), @nospecialize(name), boundscheck::
elseif isa(s, DataType)
# Can't say anything about abstract types
isabstracttype(s) && return false
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering == :not_atomic
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering === :not_atomic
# If all fields are always initialized, and bounds check is disabled, we can assume
# we don't throw
if !boundscheck && s.name.n_uninitialized == 0
Expand Down Expand Up @@ -1020,7 +1020,7 @@ function setfield!_nothrow(s00, name, v)
# Can't say anything about abstract types
isabstracttype(s) && return false
ismutabletype(s) || return false
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering == :not_atomic
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering === :not_atomic
isa(name, Const) || return false
field = try_compute_fieldidx(s, name.val)
field === nothing && return false
Expand Down
2 changes: 1 addition & 1 deletion base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ macro assume_effects(args...)
end
ex = args[end]
isa(ex, Expr) || throw(ArgumentError("Bad expression `$ex` in `@assume_effects [settings] ex`"))
if ex.head === :macrocall && ex.args[1] == Symbol("@ccall")
if ex.head === :macrocall && ex.args[1] === Symbol("@ccall")
ex.args[1] = GlobalRef(Base, Symbol("@ccall_effects"))
insert!(ex.args, 3, Core.Compiler.encode_effects_override(Core.Compiler.EffectsOverride(
consistent, effect_free, nothrow, terminates_globally, terminates_locally, notaskstate
Expand Down
2 changes: 1 addition & 1 deletion base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ function trypoptask(W::StickyWorkqueue)
# can't throw here, because it's probably not the fault of the caller to wait
# and don't want to use print() here, because that may try to incur a task switch
ccall(:jl_safe_printf, Cvoid, (Ptr{UInt8}, Int32...),
"\nWARNING: Workqueue inconsistency detected: popfirst!(Workqueue).state != :runnable\n")
"\nWARNING: Workqueue inconsistency detected: popfirst!(Workqueue).state !== :runnable\n")
continue
end
return t
Expand Down
8 changes: 4 additions & 4 deletions doc/src/manual/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,9 @@ defined to add new functionality:
julia> Base.propertynames(::Point, private::Bool=false) = private ? (:x, :y, :r, :ϕ) : (:x, :y)
julia> function Base.getproperty(p::Point, s::Symbol)
if s == :x
if s === :x
return getfield(p, :r) * cos(getfield(p, :ϕ))
elseif s == :y
elseif s === :y
return getfield(p, :r) * sin(getfield(p, :ϕ))
else
# This allows accessing fields with p.r and p.ϕ
Expand All @@ -796,12 +796,12 @@ julia> function Base.getproperty(p::Point, s::Symbol)
end
julia> function Base.setproperty!(p::Point, s::Symbol, f)
if s == :x
if s === :x
y = p.y
setfield!(p, :r, sqrt(f^2 + y^2))
setfield!(p, :ϕ, atan(y, f))
return f
elseif s == :y
elseif s === :y
x = p.x
setfield!(p, :r, sqrt(x^2 + f^2))
setfield!(p, :ϕ, atan(f, x))
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/metaprogramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ The [`Symbol`](@ref) constructor takes any number of arguments and creates a new
their string representations together:

```jldoctest
julia> :foo == Symbol("foo")
julia> :foo === Symbol("foo")
true
julia> Symbol("func",10)
Expand Down
24 changes: 12 additions & 12 deletions stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function testf(id)
@test_throws ErrorException put!(f, :OK) # Cannot put! to a already set future
@test_throws MethodError take!(f) # take! is unsupported on a Future

@test fetch(f) == :OK
@test fetch(f) === :OK
end

testf(id_me)
Expand Down Expand Up @@ -218,7 +218,7 @@ isready(f)
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == true
put!(f, :OK)
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == false
@test fetch(f) == :OK
@test fetch(f) === :OK

# RemoteException should be thrown on a put! when another process has set the value
f = Future(wid1)
Expand Down Expand Up @@ -270,7 +270,7 @@ function test_remoteref_dgc(id)

# remote value should be deleted after finalizing the ref
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == true
@test fetch(rr) == :OK
@test fetch(rr) === :OK
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == true
finalize(rr)
yield(); # flush gc msgs
Expand Down Expand Up @@ -349,7 +349,7 @@ function test_regular_io_ser(ref::Distributed.AbstractRemoteRef)
v = getfield(ref2, fld)
if isa(v, Number)
@test v === zero(typeof(v))
elseif fld == :lock
elseif fld === :lock
@test v isa ReentrantLock
@test !islocked(v)
elseif v !== nothing
Expand Down Expand Up @@ -528,7 +528,7 @@ let ex
bt = ex.captured.processed_bt::Array{Any,1}
@test length(bt) > 1
frame, repeated = bt[1]::Tuple{Base.StackTraces.StackFrame, Int}
@test frame.func == :foo
@test frame.func === :foo
@test frame.linfo === nothing
@test repeated == 1
end
Expand Down Expand Up @@ -815,11 +815,11 @@ function f13168(n)
return val
end
let t = schedule(@task f13168(100))
@test t.state == :runnable
@test t.state === :runnable
@test t.queue !== nothing
@test_throws ErrorException schedule(t)
yield()
@test t.state == :done
@test t.state === :done
@test t.queue === nothing
@test_throws ErrorException schedule(t)
@test isa(fetch(t), Float64)
Expand Down Expand Up @@ -900,7 +900,7 @@ end
take!(rc)[1] != float(i) && error("Failed")
end
return :OK
end, id_other, rc_unbuffered) == :OK
end, id_other, rc_unbuffered) === :OK

# github issue 33972
rc_unbuffered_other = RemoteChannel(()->Channel{Int}(0), id_other)
Expand Down Expand Up @@ -997,7 +997,7 @@ let
@test_throws RemoteException remotecall_fetch(bad_thunk, 2)

# Test that the stream is still usable
@test remotecall_fetch(()->:test,2) == :test
@test remotecall_fetch(()->:test,2) === :test
ref = remotecall(bad_thunk, 2)
@test_throws RemoteException fetch(ref)
end
Expand Down Expand Up @@ -1175,11 +1175,11 @@ function launch(manager::ErrorSimulator, params::Dict, launched::Array, c::Condi
dir = params[:dir]

cmd = `$(Base.julia_cmd(exename)) --startup-file=no`
if manager.mode == :timeout
if manager.mode === :timeout
cmd = `$cmd -e "sleep(10)"`
elseif manager.mode == :ntries
elseif manager.mode === :ntries
cmd = `$cmd -e "[println(x) for x in 1:1001]"`
elseif manager.mode == :exit
elseif manager.mode === :exit
cmd = `$cmd -e "exit(-1)"`
else
error("Unknown mode")
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Distributed/test/topology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ end

const map_pid_ident=Dict()
function manage(manager::TopoTestManager, id::Integer, config::WorkerConfig, op::Symbol)
if op == :register
if op === :register
map_pid_ident[id] = config.ident
elseif op == :interrupt
elseif op === :interrupt
kill(config.process, 2)
end
end
Expand Down
6 changes: 3 additions & 3 deletions stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ function varinfo(m::Module=Base.active_module(), pattern::Regex=r""; all::Bool =
end
end
end
let (col, rev) = if sortby == :name
let (col, rev) = if sortby === :name
1, false
elseif sortby == :size
elseif sortby === :size
4, true
elseif sortby == :summary
elseif sortby === :summary
3, false
else
@assert "unreachable"
Expand Down
4 changes: 2 additions & 2 deletions stdlib/InteractiveUtils/src/clipboard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ elseif Sys.iswindows()
end
ccall((:CloseClipboard, "user32"), stdcall, Cint, ()) == 0 && Base.windowserror(:CloseClipboard) # this should never fail
end
cause == :success || Base.windowserror(cause, errno)
cause === :success || Base.windowserror(cause, errno)
nothing
end
ccall((:OpenClipboard, "user32"), stdcall, Cint, (Ptr{Cvoid},), C_NULL) == 0 && return Base.windowserror(:OpenClipboard)
Expand All @@ -110,7 +110,7 @@ elseif Sys.iswindows()
clipboard(x) = clipboard(sprint(print, x)::String)
function clipboard()
function cleanup(cause)
errno = cause == :success ? UInt32(0) : Libc.GetLastError()
errno = cause === :success ? UInt32(0) : Libc.GetLastError()
if cause !== :OpenClipboard
ccall((:CloseClipboard, "user32"), stdcall, Cint, ()) == 0 && Base.windowserror(:CloseClipboard) # this should never fail
end
Expand Down
6 changes: 3 additions & 3 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const curmod_str = curmod === Main ? "Main" : join(curmod_name, ".")

@test_throws ErrorException("\"this_is_not_defined\" is not defined in module $curmod_str") @which this_is_not_defined
# issue #13264
@test (@which vcat(1...)).name == :vcat
@test (@which vcat(1...)).name === :vcat

# PR #28122, issue #25474
@test (@which [1][1]).name === :getindex
Expand Down Expand Up @@ -373,7 +373,7 @@ struct A14637
x
end
a14637 = A14637(0)
@test (@which a14637.x).name == :getproperty
@test (@which a14637.x).name === :getproperty
@test (@functionloc a14637.x)[2] isa Integer

# Issue #28615
Expand Down Expand Up @@ -615,7 +615,7 @@ end
export B41010

ms = methodswith(A41010, @__MODULE__) |> collect
@test ms[1].name == :B41010
@test ms[1].name === :B41010
end

# macro options should accept both literals and variables
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ function challenge_prompt(cmd::Cmd, challenges; timeout::Integer=60, debug::Bool

status = fetch(timer)
close(ptm)
if status != :success
if status == :timeout
if status !== :success
if status === :timeout
error("Process timed out possibly waiting for a response. ",
format_output(out))
else
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5455,7 +5455,7 @@ for (bdsdc, elty) in
elseif compq == 'P'
@warn "COMPQ='P' is not tested"
#TODO turn this into an actual LAPACK call
#smlsiz=ilaenv(9, $elty==:Float64 ? 'dbdsqr' : 'sbdsqr', string(uplo, compq), n,n,n,n)
#smlsiz=ilaenv(9, $elty === :Float64 ? 'dbdsqr' : 'sbdsqr', string(uplo, compq), n,n,n,n)
smlsiz=100 #For now, completely overkill
ldq = n*(11+2*smlsiz+8*round(Int,log((n/(smlsiz+1)))/log(2)))
ldiq = n*(3+3*round(Int,log(n/(smlsiz+1))/log(2)))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/special.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ convert(T::Type{<:UpperTriangular}, m::PossibleTriangularMatrix) = m isa T ? m :
# f(x::S, y::T) where {S,T} = x+y
# f(y::T, x::S) where {S,T} = f(x, y)
macro commutative(myexpr)
@assert myexpr.head===:(=) || myexpr.head===:function # Make sure it is a function definition
@assert Base.is_function_def(myexpr) # Make sure it is a function definition
y = copy(myexpr.args[1].args[2:end])
reverse!(y)
reversed_call = Expr(:(=), Expr(:call,myexpr.args[1].args[1],y...), myexpr.args[1])
Expand Down
16 changes: 8 additions & 8 deletions stdlib/LinearAlgebra/test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ Random.seed!(1)
@testset "Constructor and basic properties" begin
@test size(T, 1) == size(T, 2) == n
@test size(T) == (n, n)
@test Array(T) == diagm(0 => dv, (uplo == :U ? 1 : -1) => ev)
@test Array(T) == diagm(0 => dv, (uplo === :U ? 1 : -1) => ev)
@test Bidiagonal(Array(T), uplo) == T
@test big.(T) == T
@test Array(abs.(T)) == abs.(diagm(0 => dv, (uplo == :U ? 1 : -1) => ev))
@test Array(real(T)) == real(diagm(0 => dv, (uplo == :U ? 1 : -1) => ev))
@test Array(imag(T)) == imag(diagm(0 => dv, (uplo == :U ? 1 : -1) => ev))
@test Array(abs.(T)) == abs.(diagm(0 => dv, (uplo === :U ? 1 : -1) => ev))
@test Array(real(T)) == real(diagm(0 => dv, (uplo === :U ? 1 : -1) => ev))
@test Array(imag(T)) == imag(diagm(0 => dv, (uplo === :U ? 1 : -1) => ev))
end

@testset for func in (conj, transpose, adjoint)
Expand Down Expand Up @@ -356,25 +356,25 @@ Random.seed!(1)

@testset "diag" begin
@test (@inferred diag(T))::typeof(dv) == dv
@test (@inferred diag(T, uplo == :U ? 1 : -1))::typeof(dv) == ev
@test (@inferred diag(T, uplo === :U ? 1 : -1))::typeof(dv) == ev
@test (@inferred diag(T,2))::typeof(dv) == zeros(elty, n-2)
@test_throws ArgumentError diag(T, -n - 1)
@test_throws ArgumentError diag(T, n + 1)
# test diag with another wrapped vector type
gdv, gev = GenericArray(dv), GenericArray(ev)
G = Bidiagonal(gdv, gev, uplo)
@test (@inferred diag(G))::typeof(gdv) == gdv
@test (@inferred diag(G, uplo == :U ? 1 : -1))::typeof(gdv) == gev
@test (@inferred diag(G, uplo === :U ? 1 : -1))::typeof(gdv) == gev
@test (@inferred diag(G,2))::typeof(gdv) == GenericArray(zeros(elty, n-2))
end

@testset "Eigensystems" begin
if relty <: AbstractFloat
d1, v1 = eigen(T)
d2, v2 = eigen(map(elty<:Complex ? ComplexF64 : Float64,Tfull), sortby=nothing)
@test (uplo == :U ? d1 : reverse(d1)) d2
@test (uplo === :U ? d1 : reverse(d1)) d2
if elty <: Real
test_approx_eq_modphase(v1, uplo == :U ? v2 : v2[:,n:-1:1])
test_approx_eq_modphase(v1, uplo === :U ? v2 : v2[:,n:-1:1])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fabs(x::Complex) = abs(real(x)) + abs(imag(x))
function pack(A, uplo)
AP = eltype(A)[]
n = size(A, 1)
for j in 1:n, i in (uplo==:L ? (j:n) : (1:j))
for j in 1:n, i in (uplo === :L ? (j:n) : (1:j))
push!(AP, A[i,j])
end
return AP
Expand Down
6 changes: 3 additions & 3 deletions stdlib/LinearAlgebra/test/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ bimg = randn(n,2)/2
@test getproperty(bc1, uplo)*bc1.D*transpose(getproperty(bc1, uplo)) asym[bc1.p, bc1.p]
@test getproperty(bc1, uplo)*bc1.D*transpose(getproperty(bc1, uplo)) bc1.P*asym*transpose(bc1.P)
@test_throws ErrorException bc1.Z
@test_throws ArgumentError uplo == :L ? bc1.U : bc1.L
@test_throws ArgumentError uplo === :L ? bc1.U : bc1.L
end
# test Base.iterate
ref_objs = (bc1.D, uplo == :L ? bc1.L : bc1.U, bc1.p)
ref_objs = (bc1.D, uplo === :L ? bc1.L : bc1.U, bc1.p)
for (bki, bkobj) in enumerate(bc1)
@test bkobj == ref_objs[bki]
end
Expand Down Expand Up @@ -162,7 +162,7 @@ end
@test B.D == Tridiagonal([], [], [])
@test B.P == ones(0, 0)
@test B.p == []
if ul == :U
if ul === :U
@test B.U == UnitUpperTriangular(ones(0, 0))
@test_throws ArgumentError B.L
else
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/test/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,13 @@ end
# Hermitian
A = Hermitian(fill(1.0+0im, 2, 2), uplo)
@test fill!(A, 2) == fill(2, 2, 2)
@test A.data == (uplo == :U ? [2 2; 1.0+0im 2] : [2 1.0+0im; 2 2])
@test A.data == (uplo === :U ? [2 2; 1.0+0im 2] : [2 1.0+0im; 2 2])
@test_throws ArgumentError fill!(A, 2+im)

# Symmetric
A = Symmetric(fill(1.0+im, 2, 2), uplo)
@test fill!(A, 2) == fill(2, 2, 2)
@test A.data == (uplo == :U ? [2 2; 1.0+im 2] : [2 1.0+im; 2 2])
@test A.data == (uplo === :U ? [2 2; 1.0+im 2] : [2 1.0+im; 2 2])
end
end

Expand Down
Loading

0 comments on commit dd19c5a

Please sign in to comment.