From 84b55db229137d3925fe839e01d5821bb6390ab6 Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Thu, 19 Mar 2026 16:10:20 -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/pathdecomposition/pathdecomposition.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pathdecomposition/pathdecomposition.jl b/src/pathdecomposition/pathdecomposition.jl index cc93781..3109229 100644 --- a/src/pathdecomposition/pathdecomposition.jl +++ b/src/pathdecomposition/pathdecomposition.jl @@ -9,7 +9,7 @@ struct Layout{T} neighbors::Vector{T} disconnected::Vector{T} end -Base.hash(layout::Layout) = hash(layout.vertices) +Base.hash(layout::Layout, h::UInt) = hash(layout.vertices, h) function Base.:(==)(l::Layout, m::Layout) l.vsep == m.vsep && l.vertices == m.vertices end