From da41b5bd35f577215cf61a09d3dbb81c8e2d904a Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Thu, 19 Mar 2026 16:22:42 -0400 Subject: [PATCH] Fix Base.hash to use only the two-arg method Generated as part of an ecosystem-wide audit for one-arg hash methods. `Base.hash` should only be extended via the two-arg method `hash(x, h::UInt)`. Defining a one-arg `hash(x)` method, or giving the second argument a default value, can lead to correctness bugs (hash contract violations when the seed differs from the hard-coded default) and invalidation-related performance issues. This is particularly necessary for Julia 1.13+ where the default hash seed value will change. Co-Authored-By: Claude Opus 4.6 --- src/PermMatrix.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PermMatrix.jl b/src/PermMatrix.jl index aec9755..3096347 100644 --- a/src/PermMatrix.jl +++ b/src/PermMatrix.jl @@ -159,7 +159,7 @@ function Base.show(io::IO, M::AbstractPermMatrix) end end end -Base.hash(pm::AbstractPermMatrix) = hash((pm.perm, pm.vals)) +Base.hash(pm::AbstractPermMatrix, h::UInt) = hash((pm.perm, pm.vals), h) ######### sparse array interfaces ######### SparseArrays.nnz(M::AbstractPermMatrix) = length(M.vals)