You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
The `extern fn error<T>(msg: String) -> T / Throws;` declared in
`stdlib/effects.affine:29` was missing in every backend — same
dead-surface trap STDLIB-04c removed and 04e fixed for `string_to_int`.
Any caller of `use effects::{error}` would compile and fail at run with
`error is not defined`.
## Fix
Mirror `panic`'s divergent semantics with a polymorphic return type.
`<T>` unifies with whatever the call site expects (unobservable at
runtime because the call never returns), so `error("…")` is well-typed
in any expression position.
- **`interp.ml`** — `VBuiltin "error"` returning `Error (RuntimeError
msg)` (parity with `panic`).
- **`codegen_deno.ml`** — lowers to `(() => { throw new Error(msg);
})()` (parity with `panic`).
- **`resolve.ml`** — seeded alongside `panic`.
- **`typecheck.ml`** — `bind_scheme` with `poly1` so each call site
instantiates a fresh tyvar (same pattern as
`len`/`show`/`RuntimeError`).
## Tests
3 hermetic tests in `E2E STDLIB-04b error #329`:
| Test | Asserts |
|---|---|
| `error` diverges at Int call site | `RuntimeError "not positive"` |
| `error` diverges at String call site | `RuntimeError "empty key"`
(proves polymorphism — same `error` call, different unified `T`) |
| Deno codegen lowers to `throw` | emitted JS contains `throw new
Error("bad")` |
## Test plan
- [x] 3 new hermetic tests added
- [ ] CI: `dune runtest` green (e2e gate +3)
- [ ] Hypatia DOC-FORMAT: no `.md` introduced
Updates `docs/TECH-DEBT.adoc` row 04b → DONE per the audit-split
contract.
Closes#329. Refs #175.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01NUHL3MH3yKKQAEhSZn4Thu)_
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments