diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-17 17:29:56 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-17 17:29:56 -0500 |
| commit | dbd7502a1dcee6b99434f39393cb356efa542ddc (patch) | |
| tree | b8ae469719326ba2c3daf019e545c4713ab0235f /builtins/pointer.c | |
| parent | 5c49314ed4380f4e12a05888f635caa9af4a7cf4 (diff) | |
Fix up some builtins
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: |
