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

Identical child objects cause different hash of parent object #3

Open
myshkin5 opened this issue May 14, 2023 · 0 comments · May be fixed by #4
Open

Identical child objects cause different hash of parent object #3

myshkin5 opened this issue May 14, 2023 · 0 comments · May be fixed by #4

Comments

@myshkin5
Copy link

I have a parent object that holds two pointers to child objects:

type parent struct {
	c1, c2 *child
}

type child struct {
	val string
}

Then depending on whether I set both parent pointers to the same object or to two identical objects, I get different hashes:

c1 := child{val: "child"}
c2 := child{val: "child"}

p1 := parent{c1: &c1, c2: &c1}
p2 := parent{c1: &c1, c2: &c2}
ph1 := Hash(p1)
ph2 := Hash(p2)
// ph1 != ph2

This is the simplest form of the problem I'm seeing. When I saw this with functioning code, the object graph was quite a bit more complicated.

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.

1 participant