docs(specs): sync case int: formatting example with signedness-aware std.sx [F0.8]
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.
This commit is contained in:
7
specs.md
7
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user