ReviewOS

home-lang/home

Parser: support Rust-style `Type::Variant` path operator (audit-projected 30-50 files)

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

Context

The 2026-05-07 audit (kernel at 77.4% OK) shows that the dominant remaining bottleneck is 69 parse failures concentrated in arch/arm64/rpi/*, drivers/*, fs/*, net/*. Top patterns:

CountPattern
9Expected '{'
8Expected field name
7Expected semicolon or newline between statements
6Expected variable name
6Expected '}' after struct fields

Audit hypothesis: many of these are downstream of Rust-style Type::Variant enum constructor syntax. Example from kernel/src/arch/arm64/rpi/gic400.home:215:

let trig = IrqTrigger::Level   // currently fails — parser sees `:` and confuses field/type

Home has Type.Variant style (verified in earlier enum Color { Red, Green } snippets). :: is a Rust-ism that the kernel writers brought over.

Two paths

Option A: parser support — add :: as alias for .

Lex :: as a distinct token, parse Type::Variant identical to Type.Variant. Low-risk, kernel-friendly, ~30-50 files unblocked. Single small parser addition (~10-30 lines).

Option B: kernel codemod

Mass-rewrite kernel Type::Variant → Type.Variant. Bigger touch surface but no language change. Probably ~50-100 sites.

Recommendation

Option A. The :: form is widely used in the kernel (these files were ported from Rust references); accepting it as syntactic sugar costs nothing and removes a footgun. Home already accepts both [T; N] and [N]T for arrays, both error{...} and traditional Result, etc. — kernel idioms have been a common addition pattern.

Approach

  1. Reproduce: let x = IrqTrigger::Level (and IrqTrigger::Level{ ... } if applicable for tuple/struct variants)
  2. Locate the lexer (probably packages/lexer/src/lexer.zig) and add a ColonColon token type or similar
  3. In the parser, wherever . is handled for member access on type-position expressions, also accept ::
  4. Verify with sample files from the audit — arch/arm64/rpi/gic400.home, arch/arm64/rpi/uart.home, power/battery.home, etc.

Audit-flagged files for spot-check:

  • kernel/src/arch/arm64/rpi/emmc.home
  • kernel/src/arch/arm64/rpi/gic400.home
  • kernel/src/arch/arm64/rpi/gpio.home
  • kernel/src/arch/arm64/rpi/uart.home
  • kernel/src/power/battery.home
  • kernel/src/power/cpufreq_x86.home
  • kernel/src/power/thermal_x86.home

Why this matters

Single parser fix projected to unblock 30-50 files (~7-12 pp OK). Highest leverage on the post-#41 board.

Reference

  • 2026-05-07 audit: `~/Desktop/home-os-kernel-audit-2026-05-07.tsv`

Sign in to comment on this issue.