Skip to content

Fix Base.hash to use only the two-arg method#5

Open
adienes wants to merge 1 commit intofonsp:mainfrom
adienes:fix-hash-method
Open

Fix Base.hash to use only the two-arg method#5
adienes wants to merge 1 commit intofonsp:mainfrom
adienes:fix-hash-method

Conversation

@adienes
Copy link

@adienes adienes commented Mar 19, 2026

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.

This PR was generated with the assistance of generative AI.

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant