Merge pull request #244 from goccy/feature/fix-map-key-interface

Fix encoding of using empty interface as map key
This commit is contained in:
Masaaki Goshima 2021-06-06 23:06:24 +09:00 committed by GitHub
commit a2ba5e8bcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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: