reflect: fix reflect.TyepAssert for structs

This commit is contained in:
Damian Gryski
2026-04-02 13:49:26 -07:00
committed by deadprogram
parent d04332d688
commit b29edadf48
2 changed files with 47 additions and 1 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ func TypeAssert[T any](v Value) (T, bool) {
var zero T
return zero, false
}
if !v.isIndirect() {
if !v.isIndirect() && v.typecode.Size() <= unsafe.Sizeof(uintptr(0)) {
return *(*T)(unsafe.Pointer(&v.value)), true
}
return *(*T)(v.value), true