diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-10-11 15:31:38 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-10-11 15:31:38 -0400 |
| commit | 7e8604daeb9239e1669c5414dd6caa37af30c4ff (patch) | |
| tree | 8fcab61a296381280902a3fc7b2d8456e2a9b227 /src/stdlib | |
| parent | 25fa8ace21f0f6874f5b3ad1248e0e5d21190c84 (diff) | |
Make `{a,b,c}` shorthand for `{a:Empty(), b:Empty(), c:Empty()}` and
display it that way. Same for type annotations.
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/tables.c | 7 |
1 files changed, 4 insertions, 3 deletions
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)); } |
