quil-rs icon indicating copy to clipboard operation
quil-rs copied to clipboard

fix: make NaN == NaN inside Expression

Open Shadow53 opened this issue 2 years ago • 1 comments

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.

Shadow53 avatar Nov 23 '23 01:11 Shadow53

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

notmgsk avatar Dec 14 '23 20:12 notmgsk

This showed up again in #432

antalsz avatar Jan 09 '25 22:01 antalsz

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 avatar Jan 10 '25 00:01 antalsz

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 avatar Jan 10 '25 00:01 antalsz

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

github-actions[bot] avatar Jan 10 '25 01:01 github-actions[bot]

@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 avatar Jan 10 '25 01:01 antalsz

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.

erichulburd avatar Jan 10 '25 01:01 erichulburd