Skip to content

fix: remove Eq from Element and fix Struct equality#1028

Merged
popematt merged 1 commit into
amazon-ion:mainfrom
popematt:eq-fix
Jun 19, 2026
Merged

fix: remove Eq from Element and fix Struct equality#1028
popematt merged 1 commit into
amazon-ion:mainfrom
popematt:eq-fix

Conversation

@popematt

Copy link
Copy Markdown
Contributor

Issue #, if available:

fixes #1025
fixes #1026

Description of changes:

  • Element's Eq impl violated reflexivity because Value::Float uses standard f64 semantics where NaN != NaN. Remove Eq from Element, Sequence, List, SExp, and Struct.

  • Fix Struct's PartialEq to use == instead of ion_eq for field comparison, and fix a multiset matching bug where duplicate field values could all match the same target value. IonEq for Struct now independently uses ion_eq for field comparison.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

`Element`'s `Eq` impl violated reflexivity because `Value::Float` uses
standard `f64` semantics where `NaN != NaN`. Remove `Eq` from `Element`,
`Sequence`, `List`, `SExp`, and `Struct`.

Fix `Struct`'s `PartialEq` to use `==` instead of `ion_eq` for field
comparison, and fix a multiset matching bug where duplicate field values
could all match the same target value. `IonEq for Struct` now
independently uses `ion_eq` for field comparison.
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.08%. Comparing base (f57dcee) to head (4481d1e).

Files with missing lines Patch % Lines
src/types/struct.rs 98.27% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1028      +/-   ##
==========================================
+ Coverage   79.06%   79.08%   +0.02%     
==========================================
  Files         140      140              
  Lines       34809    34858      +49     
  Branches    34809    34858      +49     
==========================================
+ Hits        27520    27567      +47     
- Misses       5209     5211       +2     
  Partials     2080     2080              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@deirdresama deirdresama left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Correct fix for two real bugs, with a clean separation of PartialEq and IonEq semantics.

Minor (non-blocking): the greedy find(...) match relies on eq being a true equivalence relation; holds for both == and ion_eq, but a short comment would guard against a future non-transitive comparator.

@popematt popematt merged commit 3a392c6 into amazon-ion:main Jun 19, 2026
29 checks passed
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.

Inconsistent handling of float values in Value's impl of PartialEq Element's Eq impl violates reflexivity requirement

3 participants