ReviewOS

home-lang/home

Regression from #40: `@intCast(expr, u64)` and similar reflection arg shapes now flag `Undefined variable`

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

Context

The 2026-05-06-night audit found 28 home-os files transitioned from OK/OK → OK/TC_FAIL after home #40 landed, all with a new `error: Undefined variable` diagnostic.

Spot-check pinpointed kernel/src/sync/mutex.home:413:71 — caret on `u64` at the end of `@intCast(timeout_ms, u64)`. The tightened reflection arg-list parsing in #40 (the "user-alias type-first heuristic" sub-fix) is misclassifying primitive types in trailing arg positions as identifier references that need lookup, then failing because primitives aren't in the symbol table.

Reproduction

```home fn f(x: u32): u64 { return @intCast(x, u64) // currently fails: "Undefined variable: u64" } ```

Hypothesis

#40 sub-fix 2 ("Type-first heuristic — relax to any Identifier+Comma") combined with sub-fix 3 ("3-arg @as(T, expr, U) form — accept-and-discard trailing source-type hint") may have changed how the parser interprets the second/third arg in builtin calls. The trailing `u64` should still be recognized as a type token, not as an identifier expression.

Fix

Inspect packages/parser/src/parser.zig around lines 6287-6356 (the heuristic + 3-arg @as path from #40). Ensure that:

  • When the trailing arg is a bare primitive type identifier (`u8`/`u16`/`u32`/`u64`/`i8`/etc.), it parses as a type, not an expression
  • When it's clearly an identifier (lowercase, not a primitive), it still parses as an expression

Why this matters

Single fix unblocks ~28 files. Restores kernel OK rate from 69.3% back to ~75-76%.

Reference

  • 2026-05-06-night audit: `~/Desktop/home-os-kernel-audit-2026-05-06-night.tsv`
  • Parent: home-lang/home #40 (closed)

Sign in to comment on this issue.