diff --git a/map.go b/map.go index d9f8dd3..e5ad203 100644 --- a/map.go +++ b/map.go @@ -243,7 +243,8 @@ func (m *Map[K, V]) Clear() { } var k K var v V - for _, g := range m.groups { + for i := range m.groups { + g := &m.groups[i] for i := range g.keys { g.keys[i] = k g.values[i] = v diff --git a/map_test.go b/map_test.go index 222e3ed..503f4fe 100644 --- a/map_test.go +++ b/map_test.go @@ -216,6 +216,15 @@ func testMapClear[K comparable](t *testing.T, keys []K) { return }) assert.Equal(t, 0, calls) + + // Assert that the map was actually cleared... + var k K + for _, g := range m.groups { + for i := range g.keys { + assert.Equal(t, k, g.keys[i]) + assert.Equal(t, 0, g.values[i]) + } + } } func testMapIter[K comparable](t *testing.T, keys []K) {