|
@@ -1,12 +1,12 @@
|
|
|
# Design — ISO exceptions for V3
|
|
# Design — ISO exceptions for V3
|
|
|
|
|
|
|
|
-**Status: M1–M5 complete (2026-10-23), tag `v3-exceptions`.** `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. Gates:
|
|
|
|
|
-suite **276/276**, fixpoint OK **4,143,847 bytes**, corpus **512/612**
|
|
|
|
|
-compile-OK, 0 crashes.
|
|
|
|
|
|
|
+**Status: M1–M5 complete, plus the `functionException` follow-up
|
|
|
|
|
+(2026-10-23), tag `v3-exceptions`.** `EXCEPT`/`RETRY`, the handler
|
|
|
|
|
+stack, `SYSTEM.THROW`, `EXCEPTIONS`, `M2EXCEPTION`, `RETURN` unwinding,
|
|
|
|
|
+signal mapping, and compiler-emitted index/range/CASE/function traps are
|
|
|
|
|
+implemented. `FINALLY`, coroutine/protection exceptions and complex
|
|
|
|
|
+arithmetic remain follow-ups. Gates: suite **278/278**, fixpoint OK
|
|
|
|
|
+**4,156,434 bytes**, corpus **512/612** compile-OK, 0 crashes.
|
|
|
|
|
|
|
|
The handoff calls this the largest remaining language feature. This
|
|
The handoff calls this the largest remaining language feature. This
|
|
|
document fixes the syntax, AST, runtime model, code-generation contract,
|
|
document fixes the syntax, AST, runtime model, code-generation contract,
|
|
@@ -533,9 +533,9 @@ through the existing external-procedure path.
|
|
|
| --- | --- |
|
|
| --- | --- |
|
|
|
| `indexException` | array index check; `FPE_FLTSUB` |
|
|
| `indexException` | array index check; `FPE_FLTSUB` |
|
|
|
| `rangeException` | subrange assignment/actual/`RETURN`/`INC`/`DEC`; set element; set span |
|
|
| `rangeException` | subrange assignment/actual/`RETURN`/`INC`/`DEC`; set element; set span |
|
|
|
-| `caseSelectException` | `CASE` no match, no `ELSE` (add explicit trap) |
|
|
|
|
|
|
|
+| `caseSelectException` | `CASE` no match, no `ELSE` |
|
|
|
| `invalidLocation` | `SIGSEGV`/`SIGBUS`, NIL/uninitialised pointer |
|
|
| `invalidLocation` | `SIGSEGV`/`SIGBUS`, NIL/uninitialised pointer |
|
|
|
-| `functionException` | function body ends without `RETURN` (follow-up; current V3 returns 0) |
|
|
|
|
|
|
|
+| `functionException` | function body reaches its end without `RETURN` |
|
|
|
| `wholeValueException` | `SIGFPE` integer overflow |
|
|
| `wholeValueException` | `SIGFPE` integer overflow |
|
|
|
| `wholeDivException` | `SIGFPE` integer divide-by-zero; optional negative divisor check |
|
|
| `wholeDivException` | `SIGFPE` integer divide-by-zero; optional negative divisor check |
|
|
|
| `realValueException` | `SIGFPE` real overflow/underflow/invalid |
|
|
| `realValueException` | `SIGFPE` real overflow/underflow/invalid |
|
|
@@ -577,11 +577,13 @@ Implemented in M1–M3 (`compiler/run_tests.sh`):
|
|
|
`indexException`/`rangeException`.
|
|
`indexException`/`rangeException`.
|
|
|
- `t_except_case`: no matching `CASE` label gives
|
|
- `t_except_case`: no matching `CASE` label gives
|
|
|
`caseSelectException`.
|
|
`caseSelectException`.
|
|
|
|
|
+- `t_except_funcret`: a result function falling off its end raises
|
|
|
|
|
+ `functionException`.
|
|
|
|
|
+- `t_trap_funcret`: unhandled `functionException` aborts with rc 134.
|
|
|
- `t_except_unhandled`: expect_trap (rc=134).
|
|
- `t_except_unhandled`: expect_trap (rc=134).
|
|
|
- `t_retry_bad`: `RETRY` outside `EXCEPT` rejected with `237`.
|
|
- `t_retry_bad`: `RETRY` outside `EXCEPT` rejected with `237`.
|
|
|
|
|
|
|
|
-`functionException` and real/complex/protection/coroutine detection are
|
|
|
|
|
-still follow-ups.
|
|
|
|
|
|
|
+Real/complex/protection/coroutine detection are still follow-ups.
|
|
|
|
|
|
|
|
Use `expect_run_files` with:
|
|
Use `expect_run_files` with:
|
|
|
|
|
|
|
@@ -613,8 +615,8 @@ cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
|
|
|
tools/v3-corpus/corpus.sh
|
|
tools/v3-corpus/corpus.sh
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-Current M4 gates: suite **276/276**, fixpoint OK
|
|
|
|
|
-**4,143,847 bytes**, corpus **512/612 compile-OK**, 0 crashes.
|
|
|
|
|
|
|
+Current gates: suite **278/278**, fixpoint OK
|
|
|
|
|
+**4,156,434 bytes**, corpus **512/612 compile-OK**, 0 crashes.
|
|
|
Existing trap tests must stay rc=134.
|
|
Existing trap tests must stay rc=134.
|
|
|
|
|
|
|
|
---
|
|
---
|
|
@@ -645,8 +647,8 @@ Existing trap tests must stay rc=134.
|
|
|
`INDEX.md`; tag `v3-exceptions` at the M4 commit and a session-end
|
|
`INDEX.md`; tag `v3-exceptions` at the M4 commit and a session-end
|
|
|
tag at the docs commit.
|
|
tag at the docs commit.
|
|
|
|
|
|
|
|
-`functionException`, real/complex/protection/coroutine detection can
|
|
|
|
|
-follow separately; they should not block M1–M4.
|
|
|
|
|
|
|
+Real/complex/protection/coroutine detection can follow separately;
|
|
|
|
|
+they should not block M1–M4.
|
|
|
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
|
@@ -669,9 +671,6 @@ follow separately; they should not block M1–M4.
|
|
|
needs its own design.
|
|
needs its own design.
|
|
|
- **Coroutines:** the state/handler stack is global, not per-coroutine.
|
|
- **Coroutines:** the state/handler stack is global, not per-coroutine.
|
|
|
`coException` remains undetected.
|
|
`coException` remains undetected.
|
|
|
-- **Function result:** current V3 returns 0 when a function falls off
|
|
|
|
|
- the end; raising `functionException` is a follow-up because it can
|
|
|
|
|
- change existing behaviour.
|
|
|
|
|
- **Separate compilation:** the runtime ABI (`m2_exc_*`) is stable, but
|
|
- **Separate compilation:** the runtime ABI (`m2_exc_*`) is stable, but
|
|
|
per-unit exception tables/handler metadata would be needed once
|
|
per-unit exception tables/handler metadata would be needed once
|
|
|
objects are separate. Not part of this milestone.
|
|
objects are separate. Not part of this milestone.
|
|
@@ -689,6 +688,3 @@ follow separately; they should not block M1–M4.
|
|
|
initialization/finalization). Proposed: yes.
|
|
initialization/finalization). Proposed: yes.
|
|
|
3. Decide the exact `THROW(i)` mapping when `i` is outside
|
|
3. Decide the exact `THROW(i)` mapping when `i` is outside
|
|
|
`0 .. 14` (proposed: `exException`).
|
|
`0 .. 14` (proposed: `exException`).
|
|
|
-4. Confirm whether `functionException` should be raised now for
|
|
|
|
|
- functions with a handler whose body/handler falls through without
|
|
|
|
|
- `RETURN`; proposed: follow-up, not M1.
|
|
|