aboutsummaryrefslogtreecommitdiff
path: root/builtins/pointer.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-17 23:40:32 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-17 23:40:32 -0500
commit2345c8c5c93b8c18866f09310f8a9d9e35962823 (patch)
treec96c6b820f9ff25c0a353113ad9643671b804d45 /builtins/pointer.c
parent86f3a8054445ffe8650b7da7450234414b5b1789 (diff)
Bugfix for getting type name
Diffstat (limited to 'builtins/pointer.c')
-rw-r--r--builtins/pointer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtins/pointer.c b/builtins/pointer.c
index b661015d..2e31479a 100644
--- a/builtins/pointer.c
+++ b/builtins/pointer.c
@@ -20,10 +20,14 @@ typedef struct recursion_s {
public CORD Pointer__cord(const void *x, bool colorize, const TypeInfo *type) {
auto ptr_info = type->PointerInfo;
+ if (!x) {
+ CORD typename = generic_as_str(NULL, false, ptr_info.pointed);
+ return colorize ? CORD_asprintf("\x1b[34;1m%s%s\x1b[m", ptr_info.sigil, typename) : CORD_cat(ptr_info.sigil, typename);
+ }
const void *ptr = *(const void**)x;
if (!ptr) {
CORD typename = generic_as_str(NULL, false, ptr_info.pointed);
- return colorize ? CORD_asprintf("\x1b[34;1m!%s\x1b[m", typename) : CORD_cat(ptr_info.sigil, typename);
+ return colorize ? CORD_asprintf("\x1b[34;1m!%s\x1b[m", typename) : CORD_cat("!", typename);
}
// Check for recursive references, so if `x.foo = x`, then it prints as