diff --git a/encode_test.go b/encode_test.go index b2e5ec4..715bf4f 100644 --- a/encode_test.go +++ b/encode_test.go @@ -1912,3 +1912,9 @@ func TestIssue235(t *testing.T) { t.Fatal(err) } } + +func TestEncodeMapKeyTypeInterface(t *testing.T) { + if _, err := json.Marshal(map[interface{}]interface{}{"a": 1}); err == nil { + t.Fatal("expected error") + } +} diff --git a/internal/encoder/compiler.go b/internal/encoder/compiler.go index f9937a4..56a9604 100644 --- a/internal/encoder/compiler.go +++ b/internal/encoder/compiler.go @@ -486,8 +486,6 @@ func compileKey(ctx *compileContext) (*Opcode, error) { switch typ.Kind() { case reflect.Ptr: return compilePtr(ctx) - case reflect.Interface: - return compileInterface(ctx) case reflect.String: return compileString(ctx) case reflect.Int: