aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/reflect
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-07-28 19:00:00 +0200
committerAyke <[email protected]>2024-07-31 21:08:23 +0200
commit88f9fc3ce2802c8d79bb8205ef5d6a1be5391186 (patch)
treedc859a710b5e3d1640b77b92fe954047caeebb56 /src/reflect
parent84c376160f7a127d1beecf3f09f0f8e5caff641c (diff)
downloadtinygo-88f9fc3ce2802c8d79bb8205ef5d6a1be5391186.tar.gz
tinygo-88f9fc3ce2802c8d79bb8205ef5d6a1be5391186.zip
reflect: return correct name for unsafe.Pointer type
For some reason, the type kind name is "unsafe.Pointer" while the .Name() method just returns "Pointer". Not sure why this difference exists, but to be able to test .Name() in testdata/reflect.go it needs to match.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/type.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go
index 1356f67cd..1ac509cbb 100644
--- a/src/reflect/type.go
+++ b/src/reflect/type.go
@@ -1060,8 +1060,10 @@ func (t *rawType) Name() string {
panic("corrupt name data")
}
- if t.Kind() <= UnsafePointer {
+ if kind := t.Kind(); kind < UnsafePointer {
return t.Kind().String()
+ } else if kind == UnsafePointer {
+ return "Pointer"
}
return ""