ReviewOS

home-lang/home

Regression: `var x: [T; N]` (no init) and `var x: [T; N] align(M)` declarations silently dropped (introduced by #28)

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

Context

The 2026-05-05-evening audit found 5 home-os kernel modules where the parser silently drops `var` declarations of fixed-size arrays in two shapes, both regressions from home #28:

Shape 1: uninitialized fixed-size array

```home var packet: [u8; N] // no = undefined ```

The parser produces 0 statements for the file (silently). The next line then trips `Expected semicolon or newline`. Workaround: append `= undefined`.

Shape 2: array with align attribute

```home var x: [u32; 64] align(16) = undefined ```

Same silent-drop behavior. The combination of array-with-size-suffix and `align(N)` confuses the parser.

Affected files

  • `kernel/src/fs/fat32.home` — Shape 1
  • `kernel/src/fs/ntfs.home` — Shape 1
  • `kernel/src/iot/mqtt.home` — Shape 1
  • `kernel/src/arch/arm64/rpi/bcm2711.home` — Shape 2

Reproduction

```home fn f() { var packet: [u8; 16] // dropped silently packet[0] = 1 // "Expected semicolon" } ```

```home var x: [u32; 4] align(16) = undefined // dropped, AST has 0 statements ```

Fix

In the var-declaration parser, after parsing the type annotation `[T; N]`:

  • If next token is `=` → continue with initializer (current behavior)
  • If next token is `align(` → consume the align suffix, then optionally `= …`
  • If end-of-statement → accept as uninitialized declaration

Currently the parser is bailing in the latter cases without producing the AST node.

Why this matters

5 kernel modules unblocked. Smaller leverage than #34 but a clear correctness bug.

Reference

  • Audit: `~/Desktop/home-os-kernel-audit-2026-05-05-evening.tsv`
  • Original feature: home #28 (closed)

Sign in to comment on this issue.