-
Notifications
You must be signed in to change notification settings - Fork 763
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 incorrect __richcmp__
for eq_int
only simple enums
#4224
Conversation
Hmm interesting case. I sort of wonder if we don't need this and it's ok if adding Justification: users who've added |
@davidhewitt currently adding eq_int causes invalid equality checks and it deviates from the prior behavoir. Isn't eq_int supposed to maintain the current equality behavior? I am somewhat confused about the use cases. I had thought it was like the following:
Please correct me if I mistook the structure. |
I'll recheck (and I might be remembering wrong) - I thought the 0.21 behaviour matches (functionally, but not in implementation) what we now call |
Nice list, this is essentially what I tried to build 😅 . No equality is equivalent to I think we probably also don't want to emit a deprecation warning if |
@davidhewitt If you check this test from the 0.21 release, it will not work under the same conditions on main. @Icxolu I agree with the deprecation warning. Are you also thinking eq_int should require eq to be passed then? |
I was thinking to only emit the deprecation warning if neither |
Right I see, so we already broke it. Can we perhaps add that test of the 0.21 behaviour back under an
Fully agree with this 👍 |
That's a good idea. I added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the new test cases really help! I think we're nearly there...
tests/test_enum.rs
Outdated
py_assert!(py, var1 var2, "var1 == var2"); | ||
py_assert!(py, var1 var3, "var1 != var3"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this imply that by having eq_int
that normal equality "works" anyway (but via integer conversion presumably)?
If so, maybe it makes sense to have eq_int
require eq
to make it not a surprise that value equality works? We can always relax that requirement later I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this imply that by having
eq_int
that normal equality "works" anyway (but via integer conversion presumably)?
Yes, this is correct.
If so, maybe it makes sense to have
eq_int
requireeq
to make it not a surprise that value equality works? We can always relax that requirement later I guess.
Sure, I would love to have value comparisons only work with eq
, but I did not see a good way to archive that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! 💯
This fixes a regression that I accidentally introduced in #4210. @Zyell noticed it in #4202 (comment) 🙏
The match arms for the
eq_int
comparison would not be generated as intended ifeq
was not also specified. This should now generate the correct arms.