From 7d566d2d07efcbfa40fa12dbde652748ddcd1a42 Mon Sep 17 00:00:00 2001 From: agra Date: Fri, 5 Jun 2026 12:22:36 +0300 Subject: [PATCH] docs(specs): sync case int: formatting example with signedness-aware std.sx [F0.8] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Type Category Matching example showed the old signed-only arm (case int: result = int_to_string(xx val);), which would reproduce the pre-fix unsigned mis-rendering (u64 -> -1) if followed. Update it to mirror library/modules/std.sx:370 — branch on type_is_unsigned(type) so unsigned types route to uint_to_string, with a one-line clause explaining the split. --- specs.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/specs.md b/specs.md index 50f2288..7514ad6 100644 --- a/specs.md +++ b/specs.md @@ -1853,12 +1853,15 @@ When switching on a `Type` value (from `type_of`), category keywords match all r ```sx type := type_of(val); if type == { - case int: result = int_to_string(xx val); + case int: { + if type_is_unsigned(type) { result = uint_to_string(xx val); } + else { result = int_to_string(xx val); } + } case struct: result = struct_to_string(cast(type) val); case enum: result = enum_to_string(cast(type) val); } ``` -Available categories: `int`, `float`, `bool`, `string`, `struct`, `enum`, `vector`, `array`, `slice`, `pointer`, `type`. +Available categories: `int`, `float`, `bool`, `string`, `struct`, `enum`, `vector`, `array`, `slice`, `pointer`, `type`. The `int` arm branches on signedness — `type_is_unsigned(type)` routes unsigned types to their unsigned-decimal formatter, so values like `u64.max` print as `18446744073709551615` rather than `-1`. > Note: `case enum:` matches both payload-less enums and tagged enums (enums with payloads). C-style untagged unions are not registered with the Any type system and cannot be matched by category.