|
|
@@ -1,11 +1,12 @@
|
|
|
# Design — ISO exceptions for V3
|
|
|
|
|
|
-**Status: design + M1 parser/AST + M2 runtime/codegen + M3 libraries
|
|
|
-(2026-10-23).** `EXCEPT`/`RETRY`, the handler stack, `SYSTEM.THROW`,
|
|
|
-`EXCEPTIONS`, `M2EXCEPTION`, `RETURN` unwinding and basic signal
|
|
|
-mapping are implemented. Compiler-emitted range/index/CASE traps (M4)
|
|
|
-remain. Baseline: `v3-packedset`; suite **272/272**, fixpoint OK
|
|
|
-**4,108,488 bytes**, corpus **512/612** compile-OK, 0 crashes.
|
|
|
+**Status: design + M1–M4 implemented (2026-10-23).** `EXCEPT`/`RETRY`,
|
|
|
+the handler stack, `SYSTEM.THROW`, `EXCEPTIONS`, `M2EXCEPTION`, `RETURN`
|
|
|
+unwinding, signal mapping, and compiler-emitted index/range/CASE traps
|
|
|
+are implemented. `functionException`, `FINALLY`, coroutine/protection
|
|
|
+exceptions and complex arithmetic remain follow-ups. Baseline:
|
|
|
+`v3-packedset`; suite **275/275**, fixpoint OK **4,141,580 bytes**,
|
|
|
+corpus **512/612** compile-OK, 0 crashes.
|
|
|
|
|
|
The handoff calls this the largest remaining language feature. This
|
|
|
document fixes the syntax, AST, runtime model, code-generation contract,
|
|
|
@@ -572,14 +573,15 @@ Implemented in M1–M3 (`compiler/run_tests.sh`):
|
|
|
- `t_except_lib`: `EXCEPTIONS`/`M2EXCEPTION` `RAISE`, `CurrentNumber`,
|
|
|
`GetMessage`, `IsCurrentSource`, `IsExceptionalExecution`,
|
|
|
wrong-source `exException`, and `M2Exception` via `SYSTEM.THROW`.
|
|
|
+- `t_except_trap`: array index and subrange traps with
|
|
|
+ `indexException`/`rangeException`.
|
|
|
+- `t_except_case`: no matching `CASE` label gives
|
|
|
+ `caseSelectException`.
|
|
|
+- `t_except_unhandled`: expect_trap (rc=134).
|
|
|
- `t_retry_bad`: `RETRY` outside `EXCEPT` rejected with `237`.
|
|
|
|
|
|
-Still planned:
|
|
|
-
|
|
|
-- `t_except_basic`: a dedicated nested-handler state-restoration test
|
|
|
- (the current `t_except_lib` covers the public queries).
|
|
|
-- `t_except_trap`: integer divide-by-zero and `CASE`/range traps.
|
|
|
-- `t_except_unhandled`: expect_trap (rc=134).
|
|
|
+`functionException` and real/complex/protection/coroutine detection are
|
|
|
+still follow-ups.
|
|
|
|
|
|
Use `expect_run_files` with:
|
|
|
|
|
|
@@ -611,8 +613,8 @@ cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
|
|
|
tools/v3-corpus/corpus.sh
|
|
|
```
|
|
|
|
|
|
-Current M3 gates: suite **272/272**, fixpoint OK
|
|
|
-**4,108,488 bytes**, corpus **512/612 compile-OK**, 0 crashes.
|
|
|
+Current M4 gates: suite **275/275**, fixpoint OK
|
|
|
+**4,141,580 bytes**, corpus **512/612 compile-OK**, 0 crashes.
|
|
|
Existing trap tests must stay rc=134.
|
|
|
|
|
|
---
|
|
|
@@ -622,7 +624,7 @@ Existing trap tests must stay rc=134.
|
|
|
1. **M1 — parser/AST** — **done (2026-10-23)**
|
|
|
- `EXCEPT`, `RETRY`; `NkExcept`/`NkRetry`; `RETRY` placement check;
|
|
|
`EXCEPT` accepted in procedure, implementation, program, local
|
|
|
- module and class bodies. `EXCEPT` reports `230` until M2.
|
|
|
+ module and class bodies.
|
|
|
2. **M2 — runtime + codegen** — **done (2026-10-23)**
|
|
|
- `m2_exc_*` handler stack, `ExcBegin`/`ExcBodyDone`/`ExcHandlerBegin`/
|
|
|
`ExcEnd`/`ExcRetry`, `EmitRet` pop, `m2_exc_init` in `main`.
|
|
|
@@ -634,9 +636,10 @@ Existing trap tests must stay rc=134.
|
|
|
- `t_except_lib`: `RAISE`, `CurrentNumber`, `GetMessage`,
|
|
|
`IsCurrentSource`, `IsExceptionalExecution`, wrong-source
|
|
|
`exException`, and `M2Exception` via `SYSTEM.THROW`.
|
|
|
-4. **M4 — language traps**
|
|
|
- - `TrapCode`; split index/range; CASE trap; range-check traps; keep
|
|
|
- rc=134 for unhandled; finish `t_except_trap`.
|
|
|
+4. **M4 — language traps** — **done (2026-10-23)**
|
|
|
+ - `TrapCode`; `CheckIndex` vs `CheckRange`; CASE trap; unhandled
|
|
|
+ exceptions keep rc=134; `t_except_trap`, `t_except_case`,
|
|
|
+ `t_except_unhandled`.
|
|
|
5. **M5 — docs and corpus**
|
|
|
- Update `features.md`, `STATUS.md`, comparison table, gaps, handoff,
|
|
|
summary; commit with `v3-exceptions`; record corpus reality.
|