Skip to content

Identical child objects cause different hash of parent object #3

Description

@myshkin5

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions