8000 fix(types): -0.0 and 0.0 hash alike; a rule call's 0.0 returns -0.0's row in every run (#750) by adityamukho · Pull Request #752 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

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
adityamukho merged 1 commit into
mainfrom
fix/750-float-rule-literal
Oct 24, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/750-float-rule-literal

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Issue #750 (v2.x, data-integrity; stays open until v2.0.11 is published).

Cause

Value's derived PartialEq compares floats by IEEE == (0.0 == -0.0), but its hand-written Hash gave -0.0 and 0.0 different hashes, which breaks the Hash/Eq contract. 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.rs build side), which found -0.0 for 0.0 only when the process's random hash seed put both in the same probe group: about one run in twelve, so float_constant_test flaked.

Fix

Backport of the Hash hunk of #545 from v3: a zero of either sign hashes as 0.0. Every other float hashes as before. The rule call now returns :zero and :neg in every run, as the pattern, $slot, rule-body and = paths already do (and as v3 does).

Tests

  • types.rs unit test equal_floats_hash_alike (from v3).
  • float_constant_test: the rule-call case moves into the [":neg", ":zero"] list.
  • Loop from the issue: 0/500 failures with the fix; with the new expectation and the old hash, 300/300 failed.
  • cargo test: 1326 passed, 9 ignored. cargo clippy --all-features -D warnings clean.

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

…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
codecov Bot commented Oct 24, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 5936773 into main Oct 24, 2026
17 checks passed
@adityamukho
adityamukho deleted the fix/750-float-rule-literal branch October 24, 2026 21:31
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

0