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

Why does SortedSet use reference equality when it removes its element? #189

Closed
bglgwyng opened this issue Dec 7, 2023 · 1 comment · Fixed by #190
Closed

Why does SortedSet use reference equality when it removes its element? #189

bglgwyng opened this issue Dec 7, 2023 · 1 comment · Fixed by #190

Comments

@bglgwyng
Copy link

bglgwyng commented Dec 7, 2023

I've been using a tuple(Array in JS) as a key with SortedSet.remove.
I found that SortedSet.remove doesn't remove its element when it's not a primitive type.

So I investigated the implementation and found that removeInternal checks the reference equality before actually removing the element.
https://github.com/rimbu-org/rimbu/blob/main/packages/sorted/src/set-custom/implementation/immutable.mts#L435

Even in the case that my custom compare function returns 0, the element won't be deleted.
Just commenting that line out made remove operate as I expected.

Is this intended behavior? Or am I missing something else?

@vitoke
Copy link
Contributor

vitoke commented Dec 7, 2023

I'm pretty sure you found a genuine bug there! It should not be using reference equality, but the context.comp instance.

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 a pull request may close this issue.

2 participants