diff options
Diffstat (limited to 'builtins/pointer.c')
| -rw-r--r-- | builtins/pointer.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/builtins/pointer.c b/builtins/pointer.c index 69d11c07..e0c8b549 100644 --- a/builtins/pointer.c +++ b/builtins/pointer.c @@ -23,8 +23,10 @@ typedef struct recursion_s { public CORD Pointer__cord(const void *x, bool colorize, const TypeInfo *type) { auto ptr_info = type->PointerInfo; const void *ptr = *(const void**)x; - if (!ptr) - return colorize ? CORD_asprintf("\x1b[34;1m!%s\x1b[m", ptr_info.pointed->name) : CORD_cat(ptr_info.sigil, ptr_info.pointed->name); + if (!ptr) { + CORD typename = generic_cord(NULL, false, ptr_info.pointed); + return colorize ? CORD_asprintf("\x1b[34;1m!%s\x1b[m", typename) : CORD_cat(ptr_info.sigil, typename); + } // Check for recursive references, so if `x.foo = x`, then it prints as // `@Foo{foo=@..1}` instead of overflowing the stack: |
