From 368c7d6cda2f38865c018d86809b22cff04517dc Mon Sep 17 00:00:00 2001 From: visualfc Date: Thu, 13 Feb 2025 10:15:58 +0800 Subject: [PATCH] runtime/internal/lib/reflect: fix TypeOf check closure --- runtime/internal/lib/reflect/type.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/internal/lib/reflect/type.go b/runtime/internal/lib/reflect/type.go index 060c28dd..ea59bfaa 100644 --- a/runtime/internal/lib/reflect/type.go +++ b/runtime/internal/lib/reflect/type.go @@ -811,7 +811,11 @@ func (t *structType) FieldByName(name string) (f StructField, present bool) { // If i is a nil interface value, TypeOf returns nil. func TypeOf(i any) Type { eface := *(*emptyInterface)(unsafe.Pointer(&i)) - // closure type + // check nil + if eface.typ == nil { + return nil + } + // check closure type if eface.typ.IsClosure() { ft := eface.typ.StructType().Fields[0].Typ.FuncType() return toType(&ft.Type)