ReviewOS

home-lang/home

fix(types): diagnose missing imported namespace members

#833
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Problem

Calls to a missing member on an imported Home module namespace fall through inferCallExpression and synthesize void. A typed use then reports a downstream type mismatch instead of the missing export.

Current home-os evidence under #787:

  • scheduler.get_current_pid() resolves to void, while the module exports scheduler_get_current_pid.
  • foundation.read_cr2() resolves to void, but the module has no such export.
  • syscall.syscall_dispatch(...) resolves to void, while the module exports syscall_handler.

This obscures the source defect and creates cascaded errors.

Scope

  • Track which struct-shaped values are imported module namespaces.
  • Emit one direct missing-export diagnostic for absent namespace fields/methods.
  • Return Unknown after the primary diagnostic so typed assignments and returns do not add false type-mismatch cascades.
  • Preserve argument traversal for diagnostics and initialization tracking.

Acceptance criteria

  • A call to an exported namespace function preserves its declared return type.
  • A call to a private or absent namespace member emits a direct missing-export diagnostic.
  • A typed use of that call does not also report a void mismatch.
  • Existing type-checker tests and the home-os audit are rerun under the memory guard.

Refs #787 and #66.

8 days ago

Implemented and pushed directly to main as e067a90cb (fix(types): diagnose missing module exports (#833)).

The checker now tracks imported namespaces independently from ordinary structs, preserves namespace identity only while the binding still refers to that exact namespace type, and emits Module '<alias>' has no exported member '<name>' for missing/private bare members and calls. Missing calls still visit positional/named arguments for diagnostics and initialization tracking, then return Unknown so no false void mismatch cascades. A shadowing regression proves a local struct rebound to the import alias is not treated as a module.

Verification under the 3,840 MB guard:

  • complete Home type-system test target passed (final peak 691 MB)
  • Zig AST checks and git diff --check passed
  • scoped Pickier passed
  • fresh no-JSC home-debug build passed (peak 2,799 MB)
  • final home-os kernel audit reports 27 direct missing-export diagnostics and 4 real unsafe-boundary diagnostics, with zero former void type mismatches (peak 60 MB)
  • exactly 3 files changed

The kernel source still needs its API names and unsafe blocks corrected; this commit deliberately does not weaken those checks.

8 days ago

Acceptance criteria were completed and verified in e067a90; closing this tracker. Follow-up kernel source corrections remain tracked separately through #787 and do not require weakening the namespace diagnostics.

Sign in to comment on this issue.