Issue #989: async (ADR-async-4): errors - failure order, started/arrived sites, trace stitching

Open and answer this issue on GitHub.

blocked · opened 2026-10-30 · updated 2026-10-30 · 0 comments

Part of #983. Records: ADR-async-4 D11; ADR-async-1 D9, D16 (changed), D17. Spec: Part I 7.1 (started and arrived sites), 8.1.2 (A failure is held until it arrives), 8.2. Needs #988 (lowering).

To build

  1. The order, for every form: a catch in the task runs in the task, at once; otherwise the failure is held to where it arrives - the mention that waits (value form) or h.join() / t.join() (handles) - and an enclosing catch there takes it; otherwise the fallback (catch directly after the async expression) runs: at the wait point for the value form, inside the join for a handle, and in the task itself when it fails for a detached handle never joined; otherwise the receiver (the wait point or join throws; unread, the group’s end; a detached task nobody joins, standard error).
  2. A cancellation is not a failure: no fallback runs. task::OverBudget runs it.
  3. Unread failures at the group’s end (child handles never joined included): the fallback runs for them; on a normal end the first in written order is thrown with the rest as secondary; where a failure leaves the group, it leads and the unread ones are its secondary, in written order.
  4. The throws walk: what the fallback throws, or the task’s whole set where there is none.
  5. started and arrived sites for every form (the arrived site of a handle is its join): compile-time text, one pair per crossing, each secondary with its own; nothing on the success path.
  6. The long form prints raised, started, arrived; NIKAIA_TRACE=1 stitches with ── started at <site> ── per crossing.
  7. Tests in tests/compiler/tests/async_fail_*.nika with .stdout/.stderr: each level for the value form and for a handle; a catch at the join beating the fallback; a detached task’s fallback running in the task; a cancelled handle running no fallback; unread failures as secondary; leaving throw leads; the long form’s three lines; a chain of two crossings; a NIKAIA_TRACE=1 run.

Generated by Claude Code

Back to Open Issues