mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 05:23:40 +00:00
reflect: move indirect values into interface when setting interfaces
Fixes #4040
This commit is contained in:
@@ -1086,6 +1086,13 @@ func (v Value) Set(x Value) {
|
||||
}
|
||||
|
||||
if v.typecode.Kind() == Interface && x.typecode.Kind() != Interface {
|
||||
// move the value of x back into the interface, if possible
|
||||
if x.isIndirect() && x.typecode.Size() <= unsafe.Sizeof(uintptr(0)) {
|
||||
var value uintptr
|
||||
memcpy(unsafe.Pointer(&value), x.value, x.typecode.Size())
|
||||
x.value = unsafe.Pointer(value)
|
||||
}
|
||||
|
||||
intf := composeInterface(unsafe.Pointer(x.typecode), x.value)
|
||||
x = Value{
|
||||
typecode: v.typecode,
|
||||
|
||||
Reference in New Issue
Block a user