Skip to content

Commit 53ba43e

Browse files
aviateskFrancesco Fucci
authored andcommitted
fully normalize x == ::Symbol to x === ::Symbol (JuliaLang#45944)
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.
1 parent 0a3b93b commit 53ba43e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+152
-152
lines changed

base/compiler/tfuncs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ function getfield_nothrow(@nospecialize(s00), @nospecialize(name), boundscheck::
803803
elseif isa(s, DataType)
804804
# Can't say anything about abstract types
805805
isabstracttype(s) && return false
806-
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering == :not_atomic
806+
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering === :not_atomic
807807
# If all fields are always initialized, and bounds check is disabled, we can assume
808808
# we don't throw
809809
if !boundscheck && s.name.n_uninitialized == 0
@@ -1020,7 +1020,7 @@ function setfield!_nothrow(s00, name, v)
10201020
# Can't say anything about abstract types
10211021
isabstracttype(s) && return false
10221022
ismutabletype(s) || return false
1023-
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering == :not_atomic
1023+
s.name.atomicfields == C_NULL || return false # TODO: currently we're only testing for ordering === :not_atomic
10241024
isa(name, Const) || return false
10251025
field = try_compute_fieldidx(s, name.val)
10261026
field === nothing && return false

base/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ macro assume_effects(args...)
649649
end
650650
ex = args[end]
651651
isa(ex, Expr) || throw(ArgumentError("Bad expression `$ex` in `@assume_effects [settings] ex`"))
652-
if ex.head === :macrocall && ex.args[1] == Symbol("@ccall")
652+
if ex.head === :macrocall && ex.args[1] === Symbol("@ccall")
653653
ex.args[1] = GlobalRef(Base, Symbol("@ccall_effects"))
654654
insert!(ex.args, 3, Core.Compiler.encode_effects_override(Core.Compiler.EffectsOverride(
655655
consistent, effect_free, nothrow, terminates_globally, terminates_locally, notaskstate

base/task.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ function trypoptask(W::StickyWorkqueue)
924924
# can't throw here, because it's probably not the fault of the caller to wait
925925
# and don't want to use print() here, because that may try to incur a task switch
926926
ccall(:jl_safe_printf, Cvoid, (Ptr{UInt8}, Int32...),
927-
"\nWARNING: Workqueue inconsistency detected: popfirst!(Workqueue).state != :runnable\n")
927+
"\nWARNING: Workqueue inconsistency detected: popfirst!(Workqueue).state !== :runnable\n")
928928
continue
929929
end
930930
return t

doc/src/manual/interfaces.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,9 @@ defined to add new functionality:
785785
julia> Base.propertynames(::Point, private::Bool=false) = private ? (:x, :y, :r, :ϕ) : (:x, :y)
786786
787787
julia> function Base.getproperty(p::Point, s::Symbol)
788-
if s == :x
788+
if s === :x
789789
return getfield(p, :r) * cos(getfield(p, :ϕ))
790-
elseif s == :y
790+
elseif s === :y
791791
return getfield(p, :r) * sin(getfield(p, :ϕ))
792792
else
793793
# This allows accessing fields with p.r and p.ϕ
@@ -796,12 +796,12 @@ julia> function Base.getproperty(p::Point, s::Symbol)
796796
end
797797
798798
julia> function Base.setproperty!(p::Point, s::Symbol, f)
799-
if s == :x
799+
if s === :x
800800
y = p.y
801801
setfield!(p, :r, sqrt(f^2 + y^2))
802802
setfield!(p, :ϕ, atan(y, f))
803803
return f
804-
elseif s == :y
804+
elseif s === :y
805805
x = p.x
806806
setfield!(p, :r, sqrt(x^2 + f^2))
807807
setfield!(p, :ϕ, atan(f, x))

doc/src/manual/metaprogramming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ The [`Symbol`](@ref) constructor takes any number of arguments and creates a new
116116
their string representations together:
117117

118118
```jldoctest
119-
julia> :foo == Symbol("foo")
119+
julia> :foo === Symbol("foo")
120120
true
121121
122122
julia> Symbol("func",10)

stdlib/Distributed/test/distributed_exec.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function testf(id)
126126
@test_throws ErrorException put!(f, :OK) # Cannot put! to a already set future
127127
@test_throws MethodError take!(f) # take! is unsupported on a Future
128128

129-
@test fetch(f) == :OK
129+
@test fetch(f) === :OK
130130
end
131131

132132
testf(id_me)
@@ -218,7 +218,7 @@ isready(f)
218218
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == true
219219
put!(f, :OK)
220220
@test remotecall_fetch(k->haskey(Distributed.PGRP.refs, k), wid1, fid) == false
221-
@test fetch(f) == :OK
221+
@test fetch(f) === :OK
222222

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

271271
# remote value should be deleted after finalizing the ref
272272
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == true
273-
@test fetch(rr) == :OK
273+
@test fetch(rr) === :OK
274274
@test remotecall_fetch(k->(yield();haskey(Distributed.PGRP.refs, k)), id, rrid) == true
275275
finalize(rr)
276276
yield(); # flush gc msgs
@@ -349,7 +349,7 @@ function test_regular_io_ser(ref::Distributed.AbstractRemoteRef)
349349
v = getfield(ref2, fld)
350350
if isa(v, Number)
351351
@test v === zero(typeof(v))
352-
elseif fld == :lock
352+
elseif fld === :lock
353353
@test v isa ReentrantLock
354354
@test !islocked(v)
355355
elseif v !== nothing
@@ -528,7 +528,7 @@ let ex
528528
bt = ex.captured.processed_bt::Array{Any,1}
529529
@test length(bt) > 1
530530
frame, repeated = bt[1]::Tuple{Base.StackTraces.StackFrame, Int}
531-
@test frame.func == :foo
531+
@test frame.func === :foo
532532
@test frame.linfo === nothing
533533
@test repeated == 1
534534
end
@@ -815,11 +815,11 @@ function f13168(n)
815815
return val
816816
end
817817
let t = schedule(@task f13168(100))
818-
@test t.state == :runnable
818+
@test t.state === :runnable
819819
@test t.queue !== nothing
820820
@test_throws ErrorException schedule(t)
821821
yield()
822-
@test t.state == :done
822+
@test t.state === :done
823823
@test t.queue === nothing
824824
@test_throws ErrorException schedule(t)
825825
@test isa(fetch(t), Float64)
@@ -900,7 +900,7 @@ end
900900
take!(rc)[1] != float(i) && error("Failed")
901901
end
902902
return :OK
903-
end, id_other, rc_unbuffered) == :OK
903+
end, id_other, rc_unbuffered) === :OK
904904

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

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

11771177
cmd = `$(Base.julia_cmd(exename)) --startup-file=no`
1178-
if manager.mode == :timeout
1178+
if manager.mode === :timeout
11791179
cmd = `$cmd -e "sleep(10)"`
1180-
elseif manager.mode == :ntries
1180+
elseif manager.mode === :ntries
11811181
cmd = `$cmd -e "[println(x) for x in 1:1001]"`
1182-
elseif manager.mode == :exit
1182+
elseif manager.mode === :exit
11831183
cmd = `$cmd -e "exit(-1)"`
11841184
else
11851185
error("Unknown mode")

stdlib/Distributed/test/topology.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ end
6262

6363
const map_pid_ident=Dict()
6464
function manage(manager::TopoTestManager, id::Integer, config::WorkerConfig, op::Symbol)
65-
if op == :register
65+
if op === :register
6666
map_pid_ident[id] = config.ident
67-
elseif op == :interrupt
67+
elseif op === :interrupt
6868
kill(config.process, 2)
6969
end
7070
end

stdlib/InteractiveUtils/src/InteractiveUtils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ function varinfo(m::Module=Base.active_module(), pattern::Regex=r""; all::Bool =
6060
end
6161
end
6262
end
63-
let (col, rev) = if sortby == :name
63+
let (col, rev) = if sortby === :name
6464
1, false
65-
elseif sortby == :size
65+
elseif sortby === :size
6666
4, true
67-
elseif sortby == :summary
67+
elseif sortby === :summary
6868
3, false
6969
else
7070
@assert "unreachable"

stdlib/InteractiveUtils/src/clipboard.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ elseif Sys.iswindows()
9090
end
9191
ccall((:CloseClipboard, "user32"), stdcall, Cint, ()) == 0 && Base.windowserror(:CloseClipboard) # this should never fail
9292
end
93-
cause == :success || Base.windowserror(cause, errno)
93+
cause === :success || Base.windowserror(cause, errno)
9494
nothing
9595
end
9696
ccall((:OpenClipboard, "user32"), stdcall, Cint, (Ptr{Cvoid},), C_NULL) == 0 && return Base.windowserror(:OpenClipboard)
@@ -110,7 +110,7 @@ elseif Sys.iswindows()
110110
clipboard(x) = clipboard(sprint(print, x)::String)
111111
function clipboard()
112112
function cleanup(cause)
113-
errno = cause == :success ? UInt32(0) : Libc.GetLastError()
113+
errno = cause === :success ? UInt32(0) : Libc.GetLastError()
114114
if cause !== :OpenClipboard
115115
ccall((:CloseClipboard, "user32"), stdcall, Cint, ()) == 0 && Base.windowserror(:CloseClipboard) # this should never fail
116116
end

stdlib/InteractiveUtils/test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ const curmod_str = curmod === Main ? "Main" : join(curmod_name, ".")
245245

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

250250
# PR #28122, issue #25474
251251
@test (@which [1][1]).name === :getindex
@@ -373,7 +373,7 @@ struct A14637
373373
x
374374
end
375375
a14637 = A14637(0)
376-
@test (@which a14637.x).name == :getproperty
376+
@test (@which a14637.x).name === :getproperty
377377
@test (@functionloc a14637.x)[2] isa Integer
378378

379379
# Issue #28615
@@ -615,7 +615,7 @@ end
615615
export B41010
616616

617617
ms = methodswith(A41010, @__MODULE__) |> collect
618-
@test ms[1].name == :B41010
618+
@test ms[1].name === :B41010
619619
end
620620

621621
# macro options should accept both literals and variables

0 commit comments

Comments
 (0)