reflect: track flags when size changes from fits-in-pointer to not

Fixes #3328
Этот коммит содержится в:
Damian Gryski 2022-12-07 09:45:03 -08:00 коммит произвёл Ayke
родитель 5293d3e5f0
коммит 86f125cf72
3 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -507,7 +507,7 @@ func (v Value) Field(i int) Value {
ptr := unsafe.Pointer(uintptr(v.value) + structField.Offset) ptr := unsafe.Pointer(uintptr(v.value) + structField.Offset)
value := unsafe.Pointer(loadValue(ptr, fieldSize)) value := unsafe.Pointer(loadValue(ptr, fieldSize))
return Value{ return Value{
flags: 0, flags: flags &^ valueFlagIndirect,
typecode: fieldType, typecode: fieldType,
value: value, value: value,
} }

1
testdata/reflect.go предоставленный
Просмотреть файл

@ -129,6 +129,7 @@ func main() {
&linkedList{ &linkedList{
foo: 42, foo: 42,
}, },
struct{ A, B uintptr }{2, 3},
// interfaces // interfaces
[]interface{}{3, "str", -4 + 2.5i}, []interface{}{3, "str", -4 + 2.5i},
} { } {

14
testdata/reflect.txt предоставленный
Просмотреть файл

@ -334,6 +334,20 @@ reflect type: ptr
exported: false exported: false
reflect type: int addrable=true caninterface=false reflect type: int addrable=true caninterface=false
int: 42 int: 42
reflect type: struct
struct: 2
field: 0 A
tag:
embedded: false
exported: true
reflect type: uintptr
uint: 2
field: 1 B
tag:
embedded: false
exported: true
reflect type: uintptr
uint: 3
reflect type: slice comparable=false reflect type: slice comparable=false
slice: interface 3 3 slice: interface 3 3
pointer: true pointer: true