Fix comment for #379

This commit is contained in:
Masaaki Goshima 2022-07-07 14:52:28 +09:00
parent 8459403e25
commit 88aa13e300
No known key found for this signature in database
GPG Key ID: 6A53785055537153
1 changed files with 3 additions and 1 deletions

View File

@ -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