diff --git a/util/deephash/deephash.go b/util/deephash/deephash.go index 23d910172..955f83e55 100644 --- a/util/deephash/deephash.go +++ b/util/deephash/deephash.go @@ -342,7 +342,7 @@ func (h *hasher) hashMap(v reflect.Value) { e.SetIterValue(iter) mh.h.reset() mh.h.hashValue(k) - mh.h.hashValue(v) + mh.h.hashValue(e) sum.xor(mh.h.sum()) } h.bw.Write(append(h.scratch[:0], sum.sum[:]...)) // append into scratch to avoid heap allocation diff --git a/util/deephash/deephash_test.go b/util/deephash/deephash_test.go index bccebba62..3650beade 100644 --- a/util/deephash/deephash_test.go +++ b/util/deephash/deephash_test.go @@ -132,6 +132,15 @@ func TestDeepHash(t *testing.T) { } } +// Tests that we actually hash map elements. Whoops. +func TestIssue4868(t *testing.T) { + m1 := map[int]string{1: "foo"} + m2 := map[int]string{1: "bar"} + if Hash(m1) == Hash(m2) { + t.Error("bogus") + } +} + func getVal() []any { return []any{ &wgcfg.Config{