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.