Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: make NaN == NaN inside Expression #318

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

Shadow53
Copy link
Contributor

This is the easiest way to resolve #316 in a way that doesn't break the API (the other way being to use OrderedFloat).

Fixes #316.

Copy link
Contributor

@BatmanAoD BatmanAoD left a comment

Choose a reason for hiding this comment

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

Looks correct to me; I don't think I'm the one to make the call on actually deciding we want NaN==NaN for our users, though.

@notmgsk
Copy link
Contributor

notmgsk commented Dec 14, 2023

Hm. Not sure how to feel about this one. Part of me wants something like Expression::Nan, or Expression::Invalid(DivisionByZero)).

@antalsz
Copy link
Contributor

antalsz commented Jan 9, 2025

This showed up again in #432

@antalsz
Copy link
Contributor

antalsz commented Jan 10, 2025

In discussion with @erichulburd today, it seems like the best approach is to take this method, but make it available under a different name rather than PartialEq, and have the round_trip test use that. This should resolve the concern with NaN behaving unexpectedly politely while still allowing us to get the polite behavior.

@antalsz
Copy link
Contributor

antalsz commented Jan 10, 2025

On second thought, I'm warming to the approach here actually being correct. We claim that Expressions are Eq; that requires promising that equality is an equivalence relation, which is not currently true. It will be true if NaNs compare equal; maybe all that we need to do is document that well and then roll with this change. Thoughts? cc. @erichulburd, @Shadow53, @kalzoo

@antalsz antalsz force-pushed the 316-expression-proptest-failure branch from 39f4714 to 714eed4 Compare January 10, 2025 01:03
Copy link

github-actions bot commented Jan 10, 2025

PR Preview Action v1.6.0
Preview removed because the pull request was closed.
2025-01-14 21:33 UTC

Shadow53 and others added 2 commits January 9, 2025 20:06
This is the easiest way to resolve #316 in a way that doesn't break the
API (the other way being to use `OrderedFloat`).
@antalsz antalsz force-pushed the 316-expression-proptest-failure branch from 714eed4 to 2eba287 Compare January 10, 2025 01:06
@antalsz
Copy link
Contributor

antalsz commented Jan 10, 2025

@Shadow53 I hope you don't mind, I rebased this branch, updated the proptest seed, and added the documentation I mentioned. If this looks good to folks, I think this is ready to merge (subject to CI).

@antalsz antalsz changed the title fix: make NaN == NaN inside Expression fix!: make NaN == NaN inside Expression Jan 10, 2025
@erichulburd
Copy link
Collaborator

On second thought, I'm warming to the approach here actually being correct. We claim that Expressions are Eq; that requires promising that equality is an equivalence relation, which is not currently true. It will be true if NaNs compare equal; maybe all that we need to do is document that well and then roll with this change. Thoughts? cc. @erichulburd, @Shadow53, @kalzoo

I don't feel too strongly either way and am happy to defer to you and @Shadow53 on this.

@antalsz antalsz merged commit dde679f into main Jan 14, 2025
14 checks passed
@antalsz antalsz deleted the 316-expression-proptest-failure branch January 14, 2025 21:32
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.

Expressions containing NaN are not equal when everything else matches
5 participants