Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

hashing and equality testing for maps don't work as programmers would expect #1

Open
edfelten opened this issue May 7, 2020 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@edfelten
Copy link
Contributor

edfelten commented May 7, 2020

Equality comparison for map data types won't work as expected, in the sense that maps with the same contents can test as unequal (and have unequal hashes). This is because the internal state of a map depends on the order that keys were inserted and deleted.

One approach to this would be to guarantee that maps with equal contents always have the same internal representation. But that might not be easy or efficient.

Another approach would be to forbid hashing and equality comparison for maps (and for compound types containing maps). This would necessarily add a new "comparable" flag for compound types, which the compiler would need to track and enforce.

If we make these types non-comparable, we might want to allow programers to declare their own types non-comparable.

@edfelten edfelten added bug Something isn't working enhancement New feature or request labels May 7, 2020
@michaelsproul
Copy link

I think this is also true of ByteArray because of the internal sliceOffset

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants