@@ -141,7 +141,7 @@ func (x array) hash(t types.Type) int {
141
141
h := 0
142
142
tElt := t .Underlying ().(* types.Array ).Elem ()
143
143
for _ , xi := range x {
144
- h += hash (tElt , xi )
144
+ h += hash (t , tElt , xi )
145
145
}
146
146
return h
147
147
}
@@ -164,7 +164,7 @@ func (x structure) hash(t types.Type) int {
164
164
h := 0
165
165
for i , n := 0 , tStruct .NumFields (); i < n ; i ++ {
166
166
if f := tStruct .Field (i ); ! f .Anonymous () {
167
- h += hash (f .Type (), x [i ])
167
+ h += hash (t , f .Type (), x [i ])
168
168
}
169
169
}
170
170
return h
@@ -183,8 +183,8 @@ func (x iface) eq(t types.Type, _y interface{}) bool {
183
183
return sameType (x .t , y .t ) && (x .t == nil || equals (x .t , x .v , y .v ))
184
184
}
185
185
186
- func (x iface ) hash (_ types.Type ) int {
187
- return hashType (x .t )* 8581 + hash (x .t , x .v )
186
+ func (x iface ) hash (outer types.Type ) int {
187
+ return hashType (x .t )* 8581 + hash (outer , x .t , x .v )
188
188
}
189
189
190
190
func (x rtype ) hash (_ types.Type ) int {
@@ -256,7 +256,8 @@ func equals(t types.Type, x, y value) bool {
256
256
}
257
257
258
258
// Returns an integer hash of x such that equals(x, y) => hash(x) == hash(y).
259
- func hash (t types.Type , x value ) int {
259
+ // The outer type is used only for the "unhashable" panic message.
260
+ func hash (outer , t types.Type , x value ) int {
260
261
switch x := x .(type ) {
261
262
case bool :
262
263
if x {
@@ -308,7 +309,7 @@ func hash(t types.Type, x value) int {
308
309
case rtype :
309
310
return x .hash (t )
310
311
}
311
- panic (fmt .Sprintf ("%T is unhashable " , x ))
312
+ panic (fmt .Sprintf ("unhashable type %v " , outer ))
312
313
}
313
314
314
315
// reflect.Value struct values don't have a fixed shape, since the
0 commit comments