-
Notifications
You must be signed in to change notification settings - Fork 47
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
Interesting bug #42
Comments
So strange. 🤔 I'll take a look asap. Thanks for the report. :) |
I have a feeling it's because we're not dereferencing consistently. I don't think it's What's your code for |
It will definitely be because of the references. public function equals($obj): bool
{
return get_class($this) === get_class($obj)
&& $this->hash() === $obj->hash();
}
public function hash()
{
return (string) $this;
}
public function __toString(): string
{
return (string) $this->identity;
} Just a simple set of functions as it's a uuid. |
I think this has now been fixed in the extension? |
Great if it has! I will try to reproduce this (the code has moved on since I logged it). |
I know it's been quite a while, sorry I didn't get to this earlier. I've just done an overhaul of our tests:
To save on work, I've changed the code to not use references as described above. I thought you would want to know that there is still a references issue lurking in there somewhere. |
Thanks @designermonkey, I'll try to add a failing test for this. |
I just came across an interesting bug I thought you might like.
I have a
Set
that is being created using an array like this pseudo codeUserId
implementsHashable
.When I come to add another
UserId
to theSet
, even if thehash
functions return the same value, and theequals
functions returntrue
, the newUserId
is added to theSet
.Set
after loop and beforeadd
:Set
after loop and afteradd
Notice indexes 1 and 3
If I change the loop to the following:
Then I cannot add a new
UserId
to theSet
when theSet
already contains an object thatequals
considers to betrue
.How weird?
The text was updated successfully, but these errors were encountered: