ReviewOS

home-lang/home

Typechecker: `!u32` / `!ptr` truthiness coercion (or kernel codemod)

#39
Closed glennmichael123 opened this 24 days ago · 1 comment
24 days ago

Context

The 2026-05-06 audit shows 4 home-os kernel modules failing with `error: Logical not requires boolean or optional operand` on patterns like:

if (!some_u32_value) { ... }      // C-style "is zero" test
if (!some_pointer) { ... }         // C-style "is null" test

Design question

Two options:

  1. Accept C-style truthiness: `!` on int → `x == 0`; `!` on pointer → `x == null` (or analogous). Low-effort parser patch, matches what kernel writers naturally wrote.
  2. Reject and codemod kernel: keep current strict typing, rewrite kernel to `x == 0` / `x == null`. ~4 sites.

Option 1 is more ergonomic but introduces an implicit coercion that contradicts Home's "explicit init" / Zig-philosophy direction. Option 2 is more consistent.

Recommended: Option 2 (kernel codemod) — small enough to be trivial, keeps the language's explicit-typing posture.

If you pick Option 2, file as a home-os kernel codemod issue and close this on the compiler side.

Affected files

Filter audit for `Logical not requires`. ~4 files.

Reference

  • 2026-05-06 audit
24 days ago

Closing as wontfix per the design call: option 2 (codemod kernel, keep compiler strict).

Home keeps the strict typing for ! — boolean / optional only. C-style truthiness on u32 / raw *T would be an implicit coercion that contradicts the language's "explicit init" / Zig-philosophy direction.

Tracked on the kernel side: home-lang/home-os#20 (codemod the four affected files: arch/arm64/rpi/{boot,emmc,gic400,mailbox}.home).

Sign in to comment on this issue.