ReviewOS

home-lang/home

fix(types): recognize `never` as the Home bottom type

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

Problem

Home already models Type.Never, documents never, treats it as a subtype of every type, and lowers never kernel functions without a normal epilogue. The authoritative Home source-type parser does not recognize the never spelling, however, so valid diverging function signatures report Unknown type 'never'. Its internal coercion helper also omits the bottom-type rule documented by the language.

Evidence

The current home-os origin/main kernel entry declares export fn kernel_main(...): never and fails type checking at that annotation. Type.isSubtype and Type.canCoerceTo already encode bottom-type behavior, while TypeChecker.parseTypeName and the checker's private canCoerce do not.

Scope

  • Parse never as Type.Never in Home source annotations.
  • Permit a never expression wherever a value type is expected.
  • Add focused checker coverage and align the language documentation with the enforced behavior.

Acceptance criteria

  • A diverging function may declare : never without an unknown-type error.
  • Calling a never function is valid in a return position expecting another type.
  • The focused authoritative checker suite remains green.

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

9 days ago

Landed 97d8262d8 directly on main as fix(types): recognize the never bottom type (#824).

The authoritative Home checker now resolves the never source spelling to its existing Type.Never representation and applies the bottom-type coercion rule in ordinary value contexts. Added coverage proving a diverging function can be returned from an i32 function, and clarified the language reference.

Verification:

  • Focused authoritative checker suite: 67/67 passed, guarded peak 347 MB.
  • Rebuilt the no-JSC compiler: guarded peak 2,806 MB.
  • Current home-os origin/main kernel snapshot: type errors dropped 87 → 82, removing all five Unknown type 'never' failures; guarded peak 122 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.