From 7e8604daeb9239e1669c5414dd6caa37af30c4ff Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 11 Oct 2025 15:31:38 -0400 Subject: Make `{a,b,c}` shorthand for `{a:Empty(), b:Empty(), c:Empty()}` and display it that way. Same for type annotations. --- src/stdlib/tables.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/stdlib/tables.c') diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c index c093e4c2..fdd85b56 100644 --- a/src/stdlib/tables.c +++ b/src/stdlib/tables.c @@ -534,8 +534,9 @@ Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *type) { __typeof(type->TableInfo) table = type->TableInfo; if (!t) { - return Text$concat(Text("{"), generic_as_text(NULL, false, table.key), Text(":"), - generic_as_text(NULL, false, table.value), Text("}")); + return table.value->size > 0 ? Texts("{", generic_as_text(NULL, false, table.key), ":", + generic_as_text(NULL, false, table.value), "}") + : Texts("{", generic_as_text(NULL, false, table.key), "}"); } int64_t val_off = (int64_t)value_offset(type); @@ -544,7 +545,7 @@ Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *type) { if (i > 0) text = Text$concat(text, Text(", ")); void *entry = GET_ENTRY(*t, i); text = Text$concat(text, generic_as_text(entry, colorize, table.key)); - if (table.value != &Void$info) + if (table.value->size > 0) text = Text$concat(text, Text(": "), generic_as_text(entry + val_off, colorize, table.value)); } -- cgit v1.2.3