Fix encoding of using empty interface as map key

This commit is contained in:
Masaaki Goshima 2021-06-06 20:39:49 +09:00
parent ad04977db7
commit edd09e7470
2 changed files with 6 additions and 2 deletions

View File

@ -1912,3 +1912,9 @@ func TestIssue235(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }
func TestEncodeMapKeyTypeInterface(t *testing.T) {
if _, err := json.Marshal(map[interface{}]interface{}{"a": 1}); err == nil {
t.Fatal("expected error")
}
}

View File

@ -486,8 +486,6 @@ func compileKey(ctx *compileContext) (*Opcode, error) {
switch typ.Kind() { switch typ.Kind() {
case reflect.Ptr: case reflect.Ptr:
return compilePtr(ctx) return compilePtr(ctx)
case reflect.Interface:
return compileInterface(ctx)
case reflect.String: case reflect.String:
return compileString(ctx) return compileString(ctx)
case reflect.Int: case reflect.Int: