Context
Two small follow-ups: 4 missing reflection builtins (~4 kernel files) + a typecheck regression introduced by home #20 (~2 files).
Sub-item A: 4 missing reflection builtins
Same shape as home #27. Needed by home-os kernel:
| Builtin | Purpose | Suggested signature |
|---|---|---|
@intToU64 | Convert any integer to u64 | fn(value: anyInt) -> u64 |
@alignCast | Cast pointer to a more-aligned variant | fn(comptime alignment: u64, ptr: *T) -> *align(alignment) T |
@atomicFetchSub | Atomic fetch-then-subtract | fn(ptr: *T, val: T) -> T |
@atomicFetchAdd | Atomic fetch-then-add | fn(ptr: *T, val: T) -> T |
Add to wherever home #27 added @addrOf/@atomicCmpXchg/@intFromEnum — same pattern.
Sub-item B: switch case pattern type coercion regression
home #20 introduced a regression: switch with => arms now requires the case patterns to exactly match the switch value's type. Previously, char/int literals coerced.
fn classify(c: u8): u32 {
switch (c) {
'(' => return 1, // ERROR: "Case pattern type must match switch value type"
')' => return 2,
else => return 0,
}
}'(' is a char literal; c is u8. The literal should coerce to u8. Similar issue for int literals (0 => against a u32 switch value).
Affected files: kernel/src/i18n/bidi.home, kernel/src/net/smb.home.
Approach
For sub-item B: in the switch typechecker, allow case patterns to coerce to the switch value's type using the same coercion rules as let/var/argument types (now improved by home #21/#26+27). A char literal is fundamentally a small int; it should fit u8.
Why this matters
6 kernel modules unblocked. Plus closing the regression keeps #20's scoreboard honest.