ReviewOS

home-lang/home

fix(types): resolve quoted Home imports relative to their importer

#823
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

The authoritative type checker cannot resolve quoted Home imports that already include a source extension. For a kernel entry at src/main.home, an import such as import "core/kernel_init.home" as kernel_init is searched as src/core/kernel_init.home.home, so home build src/main.home --kernel fails before it can validate the kernel corpus.

Evidence

Against current origin/main, running the Home compiler on the home-os kernel entry reports Cannot resolve import 'core/kernel_init.home': FileNotFound plus 130 more import errors. The parser's module resolver understands file-like imports, but TypeChecker.resolveModulePath independently appends .home to every path and resolves package roots rather than the importing file's directory.

Scope

  • Resolve a single quoted file path relative to the importing source file.
  • Preserve .home and .hm extensions instead of appending another extension.
  • Keep package-style imports and their existing fallback order unchanged.
  • Add a kernel-shaped regression fixture and exercise it through the authoritative checker.

Acceptance criteria

  • import "core/kernel_init.home" from src/main.home resolves src/core/kernel_init.home.
  • Existing package-style import tests remain green.
  • The home-os kernel corpus advances past its root import-resolution failures.

Blocks the remaining kernel-corpus acceptance item in #787. Part of #814.

9 days ago

Landed 26722c5cb directly on main as fix(types): resolve quoted source imports (#823).

The authoritative type checker now delegates import lookup to the parser's path-aware ModuleResolver, removing the duplicate resolver that appended .home to already-complete quoted paths. Added a kernel-shaped regression for src/main.home importing core/kernel_init.home.

Verification:

  • zig build test -Dfilter=types_control_flow -j1 --summary all: 3/3 build steps succeeded (focused checker suite cached after the fresh passing run); guarded peak 162 MB.
  • Rebuilt home-debug with -Denable_jsc=false: guarded peak 2,847 MB.
  • Real home-os corpus: root import failures dropped from 135 to zero; compilation now reaches 27 genuine semantic type errors instead of stopping at FileNotFound; guarded peak 53 MB.

The commit contains exactly three files and was pushed directly to origin/main as glennmichael123 <gtorregosa@gmail.com> with no coauthors.

Sign in to comment on this issue.