ReviewOS

home-lang/home

fix: implement the panic builtin end to end

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

Problem

The checked examples and the built-in assert!, debug_assert!, todo!, unimplemented!, and unreachable! macros expand to panic(message), but panic is not registered in the type environment and has no native lowering. Current home check examples/ therefore reports Undefined function 'panic' across five example files.

Scope

  • Register panic: fn(string) -> never in the checker.
  • Preserve bottom-type behavior so panic branches satisfy surrounding expression types.
  • Lower source-level panic on supported native backends by writing the message to stderr and terminating with exit code 101.
  • Add focused checker and executable regressions.
  • Re-run scripts/check-examples.sh and report the remaining independent failures.

Acceptance criteria

  • panic requires exactly one string argument and has type never.
  • A panic branch type-checks where another branch returns a concrete value.
  • Native panic prints its message and exits 101.
  • Macro-expanded panic calls no longer fail as undefined functions.

Part of #779 and #814.

8 days ago

Pushed b663c1e0a (fix(types): type the panic builtin as never) and 922a50a85 (fix(codegen): lower source panic calls) directly to origin/main, both authored/committed as glennmichael123 <gtorregosa@gmail.com> with no coauthors.

The checker now registers panic: fn(string) -> never, validates arity/message type, and preserves bottom-type coercion. x64 lowers runtime string messages to stderr plus exit 101; AArch64 lowers literal messages through its existing static-string capability plus exit 101. Guarded verification: checker 71/71 and codegen 19/19, with the latter executing the x64 panic path and validating the AArch64 payload. The issue stays open until the freshly rebuilt compiler completes the examples rebaseline.

8 days ago

Completed on origin/main by b663c1e0a and 922a50a85. Final guarded validation used a freshly rebuilt no-JSC compiler (2,772 MB peak): scripts/check-examples.sh improved from 30 pass / 9 fail to 34 pass / 5 fail. Every prior Undefined function 'panic' diagnostic is gone, including macro-expanded calls. Focused suites remain 71/71 checker and 19/19 codegen. The five remaining examples failures are independent async, ownership/drop, and macro-negation issues tracked through #779.

Sign in to comment on this issue.