Repository navigation
fix(types): -0.0 and 0.0 hash alike; a rule call's 0.0 returns -0.0's row in every run (#750) - #752
Merged
Merged
Conversation
…0's row in every run (#750) Value's PartialEq compares floats by IEEE ==, so 0.0 == -0.0, but its Hash gave them different hashes, breaking the Hash/Eq contract. A rule call's literal reaches the rule through the magic-sets seed and a hash join, which paired 0.0 with -0.0 only when the random hash seed put them in the same probe group: about one run in twelve. Backports the Hash hunk of #545 from v3; the test now expects both rows, as every other float-constant path returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #750 (v2.x, data-integrity; stays open until v2.0.11 is published).
Cause
Value's derivedPartialEqcompares floats by IEEE==(0.0 == -0.0), but its hand-writtenHashgave-0.0and0.0different hashes, which breaks theHash/Eqcontract. A rule call's literal ((xval ?e 0.0)) reaches the rule as a magic-sets seed and is joined through a hash table (matcher.rsbuild side), which found-0.0for0.0only when the process's random hash seed put both in the same probe group: about one run in twelve, sofloat_constant_testflaked.Fix
Backport of the
Hashhunk of #545 from v3: a zero of either sign hashes as0.0. Every other float hashes as before. The rule call now returns:zeroand:negin every run, as the pattern,$slot, rule-body and=paths already do (and as v3 does).Tests
types.rsunit testequal_floats_hash_alike(from v3).float_constant_test: the rule-call case moves into the[":neg", ":zero"]list.cargo test: 1326 passed, 9 ignored.cargo clippy --all-features -D warningsclean.No v3 PR: v3 already has this (#545). No docs-site change: the join-rules text is
@since v3.0.0.🤖 Generated with Claude Code
https://claude.ai/code/session_01Urda7FD9CYYoxdeGGJa11x