Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ hash(data::Any) = hash(data, HASH_SEED)
hash(w::WeakRef, h::UInt) = hash(w.value, h)

# Types can't be deleted, so marking as total allows the compiler to look up the hash
hash(T::Type, h::UInt) =
hash((@assume_effects :total ccall(:jl_type_hash, UInt, (Any,), T)), h)
@assume_effects :total _jl_type_hash(T::Type) = ccall(:jl_type_hash, UInt, (Any,), T)
hash(T::Type, h::UInt) = hash(_jl_type_hash(T), h)
hash(@nospecialize(data), h::UInt) = hash(objectid(data), h)

function mul_parts(a::UInt64, b::UInt64)
Expand Down
8 changes: 7 additions & 1 deletion test/hashing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,10 @@ struct AUnionParam{T<:Union{Nothing,Float32,Float64}} end
@test hash(5//3) == hash(big(5)//3)
end

@test Core.Compiler.is_foldable_nothrow(Base.infer_effects(hash, Tuple{Type{Int}, UInt}))
@testset "concrete eval type hash" begin
@test Core.Compiler.is_foldable_nothrow(Base.infer_effects(hash, Tuple{Type{Int}, UInt}))

f(h...) = hash(Char, h...);
src = only(code_typed(f, Tuple{UInt}))[1]
@test count(stmt -> Meta.isexpr(stmt, :foreigncall), src.code) == 0
end