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 [Record] HashableAttribute (runtime error) #1114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

StefanBertels
Copy link
Contributor

@StefanBertels StefanBertels commented Sep 21, 2022

Using [Hashable(...)] in [Record] results in runtime error.

Found this bug because I didn't use [Hashable(...)] but just [Eq(...)] and [Ord(...)] resulting in different hash codes.


IMHO it's error-prone (and boilerplate) to require all three attributes for simple cases like the one shown in the test case.

GetHashCode maybe should be implemented by using the first existing of

  1. [Hashable]
  2. [Eq]
  3. [Ord]
  4. HashDefault

I'm not sure whether Ord should (or does) fully superseed Eq which could result in a similar list for implementation of Equals. I often use [Record] types having one or more case insensitive string properties as keys for e.g. Map and HashMap or with .GroupBy(..).

Edit: somehow related to #842 (CompareTo==0 vs. Equals==true)

@StefanBertels StefanBertels changed the title Fix hashable Fix [Record] HashableAttribute Sep 21, 2022
@StefanBertels StefanBertels changed the title Fix [Record] HashableAttribute Fix [Record] HashableAttribute (runtime error) Feb 5, 2023
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.

None yet

1 participant