ReviewOS

home-lang/home

Add missing reflection builtins: `@addrOf`, `@atomicCmpXchg`, `@intFromEnum`

#27
Closed glennmichael123 opened this 24 days ago · 0 comments
24 days ago

Context

The 2026-05-04-night audit shows 6 home-os kernel files failing because the parser doesn't recognize three builtin functions:

BuiltinFilesPurpose
@addrOf3Take address of an lvalue (alternative to &x)
@atomicCmpXchg2Atomic compare-exchange
@intFromEnum1Convert enum variant to its underlying integer

Approach

These are small parser-table additions plus typechecker support. Find where existing reflection builtins (@as, @ptrCast, @truncate, @bitCast, @intCast, @ptrFromInt, etc.) are registered in the parser/typechecker, and add the three new ones with appropriate signatures:

  • @addrOf(expr) → *T where T is the type of expr. Equivalent to &expr.
  • @atomicCmpXchg(ptr: *T, expected: T, desired: T) -> ?T — returns previous value if exchange failed, null if succeeded.
  • @intFromEnum(variant) -> integer — extracts the integer tag of an enum variant.

Why this matters

6 home-os kernel modules unblocked. Small grammar/checker additions, low LoC each.

Reference

  • Audit: ~/Desktop/home-os-kernel-audit-2026-05-04-night.tsv

Sign in to comment on this issue.