/** * try / catch / finally runtime semantics — catch-all, canonical errors (D2). * * Structure: `catch` and `finally` are CHILD nodes of `try` (the way `branch` * models its `path` children); everything else under `try` is the protected * body. At most one `catch` and one `finally`; a `try` with neither is an * orphan and fails preconditions. * * Operational semantics: * 1. Run the try body. * 2. If it completes `{kind:"throw"}` AND a `catch` is present, run the catch * body; the catch's completion replaces the body's. (Catch-all only this * slice — the single catch handles every canonical error.) * 3. If a `finally` is present, run it on EVERY path. It is cleanup-only: it * must complete normally, and it preserves the prior completion. A finally * that itself completes abruptly is out of domain (the finally-overrides- * completion trap) and raises a reference error. * 4. Event order: try/catch events first, then finally events, then the final * completion (normal | return | throw{error:{kind,messagePattern}}). * * Domain / exclusions (D2): * - The only error source is an EXPLICIT `throw` of a canonical KERN error * (modeled by the `throw` primitive -> `{kind, messagePattern}`). * - Catch bodies do NOT read the error binding — raw-error field access * diverges (JS error object vs Python exception) and is out of domain. * - When a `catch` is present the try body must not `return` (in the emitter * legs a body `return` lowers to a sentinel the `catch`/`except Exception` * would wrongly intercept; the reference would propagate it). A finally- * only `try` (no catch) MAY contain a propagating return/throw. * - Typed/multi-catch, implicit runtime errors (null-deref, div-by-zero), * throwing primitives, and abrupt finally are deferred to a later contract. */ import { type NodeContract } from './index.js'; export declare const tryContract: NodeContract; /** Idempotent registration. Test cleanup that clears the registry must re-call. */ export declare function registerTryContract(): void; /** Reset registration flag — only for test cleanup that clears the registry. */ export declare function _resetTryContractForTest(): void;