From dbd7502a1dcee6b99434f39393cb356efa542ddc Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 17 Feb 2024 17:29:56 -0500 Subject: Fix up some builtins --- builtins/pointer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builtins/pointer.c') 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: -- cgit v1.2.3