From 288cf0c01cc3dcac9c54e201609aaefe51049307 Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Thu, 19 Mar 2026 16:20:48 -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/terms.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terms.jl b/src/terms.jl index 6b9b376..8b040e1 100644 --- a/src/terms.jl +++ b/src/terms.jl @@ -170,7 +170,7 @@ import Base.< import Base.isless isless(t1::Term, t2::Term) = (t1 < t2) -Base.hash(t::Term) = hash((t.L,t.S,t.parity)) +Base.hash(t::Term, h::UInt) = hash((t.L,t.S,t.parity), h) include("xu2006.jl")