From 7484e61b7f34febb0210a65c22e59128a92fd069 Mon Sep 17 00:00:00 2001 From: Andy Dienes Date: Thu, 19 Mar 2026 16:29:03 -0400 Subject: [PATCH] Fix incorrect one-arg Base.hash method Generated as part of an ecosystem-wide audit for one-arg hash methods. The `hash(arg::LowerOrUpperIndex)` method only defined a one-arg `Base.hash`, which means the two-arg fallback `hash(x, h::UInt)` uses `objectid`-based hashing instead. This can cause correctness issues (equal objects hashing differently) and performance problems (excessive invalidation). With Julia 1.13+, the default hash seed is changing from `zero(UInt)` to a random value, which will make the one-arg method produce different results on each session. Fix by converting to a proper two-arg method that chains the seed `h` through the hash computation. Co-Authored-By: Claude --- src/index.jl | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/index.jl b/src/index.jl index 263d283..74e825f 100644 --- a/src/index.jl +++ b/src/index.jl @@ -42,14 +42,11 @@ function same_to(old::Upper, letter::Letter) return Upper(letter) end -function hash(arg::LowerOrUpperIndex) - h::UInt = 0 - +function hash(arg::LowerOrUpperIndex, h::UInt) + val::UInt = 0 if typeof(arg) == Lower - h |= 1 + val |= 1 end - - h |= arg.letter << 1 - - h + val |= arg.letter << 1 + hash(val, h) end