aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorDamian Gryski <[email protected]>2023-03-15 12:24:36 -0700
committerDamian Gryski <[email protected]>2023-03-15 13:14:21 -0700
commit9f02340a26f24e00e0b6da622b9cbbf1c6e05e26 (patch)
tree07dc573c2226d0ee01918a2395a2b95c53958768 /src
parentc6728643e64a5eaa407930c1c8c80f05aa3890e2 (diff)
downloadtinygo-9f02340a26f24e00e0b6da622b9cbbf1c6e05e26.tar.gz
tinygo-9f02340a26f24e00e0b6da622b9cbbf1c6e05e26.zip
reflect: fix Type.Name to return empty string for non-named types
// Name returns the type's name within its package for a defined type. // For other (non-defined) types it returns the empty string.
Diffstat (limited to 'src')
-rw-r--r--src/reflect/type.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go
index c7c05cecc..d91d6faf8 100644
--- a/src/reflect/type.go
+++ b/src/reflect/type.go
@@ -923,7 +923,11 @@ func (t *rawType) Name() string {
return readStringZ(unsafe.Pointer(&ntype.name[0]))
}
- return t.Kind().String()
+ if t.Kind() <= UnsafePointer {
+ return t.Kind().String()
+ }
+
+ return ""
}
func (t *rawType) Key() Type {