Skip to content

Commit

Permalink
Fix comment for #379
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Jul 7, 2022
1 parent 8459403 commit 88aa13e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/encoder/compiler.go
Expand Up @@ -487,7 +487,9 @@ func (c *Compiler) listElemCode(typ *runtime.Type) (Code, error) {
case typ.Kind() == reflect.Map:
return c.ptrCode(runtime.PtrTo(typ))
default:
// Strictly not isPtr == true, but reflect.ValueOf().Index() is canAddr, so set isPtr == true.
// isPtr was originally used to indicate whether the type of top level is pointer.
// However, since the slice/array element is a specification that can get the pointer address, explicitly set isPtr to true.
// See here for related issues: https://github.com/goccy/go-json/issues/370
code, err := c.typeToCodeWithPtr(typ, true)
if err != nil {
return nil, err
Expand Down

0 comments on commit 88aa13e

Please sign in to comment.