Skip to content

Commit a9ad80b

Browse files
committed
started to move to Base.hash for type hashes
1 parent dc201bc commit a9ad80b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/StructEqualHash.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ module StructEqualHash
88

99
export @struct_equal_hash
1010

11-
Base.@assume_effects :foldable typeid(T::Type) = objectid(T)
12-
13-
typehash(::Type{T}, h::UInt = UInt(0)) where T = hash(3*h-typeid(T))
11+
if VERSION < v"1.11"
12+
Base.@assume_effects :foldable typeid(T::Type) = objectid(T)
13+
typehash(::Type{T}, h::UInt = UInt(0)) where T = hash(typeid(T), h)
14+
else
15+
# `hash(T, h)` should work, but we have to work around julia#58395
16+
typehash(::Type{T}, h::UInt = UInt(0)) where T = hash(hash(T), h)
17+
end
1418

1519
totuple(x, fields) = map(name -> getfield(x, name), fields)
1620
totuple(x::T, ::Missing) where T = totuple(x, fieldnames(T))

0 commit comments

Comments
 (0)