Просмотр исходного кода

docs: 2026-10-23 summary, handoff and updated comparison (range checks)

Eric Streit 14 часов назад
Родитель
Сommit
2d1c658ca1
3 измененных файлов с 183 добавлено и 5 удалено
  1. 8 5
      docs/INDEX.md
  2. 115 0
      docs/handoff-2026-10-23-next.md
  3. 60 0
      docs/summary_session-2026-10-23.md

+ 8 - 5
docs/INDEX.md

@@ -6,9 +6,10 @@ bisecting *why* a decision was made, not for reading end-to-end).
 
 ## Start here
 
-- **`handoff-2026-10-22-next.md`** — next-session plan from the
-  2026-10-22 stop point (PACKEDSET, exceptions, multi-dim open arrays,
-  range checks; gates).
+- **`handoff-2026-10-23-next.md`** — current next-session plan
+  (PACKEDSET representation, exceptions, multi-dim open arrays; gates).
+- **`handoff-2026-10-22-next.md`** — previous stop-point plan (range
+  checks, PACKEDSET inspection; kept for provenance).
 - **`handoff-2026-10-19-next.md`** — previous plan (P1–P5 status, the
   ASTDUMP root cause).
 - **`git-branches-tags.md`** — branch/tag map (which refs are current,
@@ -18,8 +19,8 @@ bisecting *why* a decision was made, not for reading end-to-end).
 - **`plan.md`** — the phased plan (Blaise-adapted).
 - **`features.md`** — the feature list.
 - **`comparison-PIM4-gm2-V3.md`** — PIM4 / GNU Modula-2 / **M2R10** /
-  **TopSpeed V3** / V3 feature comparison (2026-10-22; V3 at
-  `v3-smallfix`; filename kept for link stability).
+  **TopSpeed V3** / V3 feature comparison (2026-10-23; V3 at
+  `v3-rangechecks`; filename kept for link stability).
 - **`analysis_gaps.md`** — language gaps + corpus notes.
 - **`gaps/README.md`** — minimal reproducers, one per unsupported gap,
   and the gm2-extension policy.
@@ -43,6 +44,8 @@ bisecting *why* a decision was made, not for reading end-to-end).
 
 ## Recent session summaries (newest first)
 
+- **`summary_session-2026-10-23.md`** — continuation: runtime subrange
+  range checks (+3 trap tests); PACKEDSET inspected and parked.
 - **`summary_session-2026-10-22.md`** — corpus triage: PIM/ISO
   multi-index arrays, typed CHAR/enum subranges, ordinal `FOR`, ISO
   empty string, typed libc prototypes, ISO SYSTEM sized types,

+ 115 - 0
docs/handoff-2026-10-23-next.md

@@ -0,0 +1,115 @@
+# Next session — plan (from 2026-10-23)
+
+**Branch:** `master`.  **Feature state:** `v3-rangechecks`.
+**Gates:** suite **262/262**, fixpoint **OK (4,032,793 bytes)**,
+corpus **511/612, 0 crashes**.
+
+Read first: `docs/STATUS.md`, `docs/features.md`,
+`docs/gaps/README.md`, `docs/summary_session-2026-10-23.md`.
+
+## Policy reminder
+
+V3 follows **PIM/ISO Modula-2**, not gm2 leniencies.  Declaration before
+use is required for data; only a `POINTER`'s base may forward-reference.
+gm2 compatibility is accepted only where documented in `docs/gaps/`.
+
+## 1. `PACKEDSET` — 3 files (`onebyte`, `onebyte2`, `onebyte3`)
+
+Inspected 2026-10-23; **not** a safe alias to `SET`:
+
+- `SIZE(PACKEDSET OF [0..7]) = SIZE(BYTE) = 1` (asserted);
+- `ORD(set)` is used (`ORD(si) = 2`, `ORD(se) = 32`);
+- arrays of packed sets (`onebyte3`) check neighbouring bytes.
+
+A faithful implementation needs:
+
+- a type form/class for packed sets with a **byte width**
+  (`ceil(span / 8)`; 1/2/4 bytes for the corpus, possibly an impl limit
+  beyond 32 bits);
+- `TypeSize`/`ElemBytes` = width; `SIZE` = width;
+- packed loads/stores (`loadub`/`loaduh`/`loadw` + `storeb`/`storeh`/
+  `storew`) for variables, fields, arrays and parameters;
+- set operations on packed masks: literal, assignment, `INCL`/`EXCL`,
+  `IN`, `=/#`, union/diff/intersection, `ORD` of a set;
+- range/mask checks consistent with the set span.
+
+Until then, the three corpus files stay `LANG` (documented in
+`docs/gaps/README.md`).  Do not map `PACKEDSET` to `SET` merely to raise
+the compile count.
+
+## 2. ISO exceptions — 7 files (`except2/4/5/7/8/9`, `lazyunique`)
+
+A dedicated feature session, not a small fix:
+
+- `EXCEPT` / `RETRY` after a normal statement sequence (procedures and
+  module bodies);
+- `EXCEPTIONS` (`AllocateSource`, `RAISE`, `CurrentNumber`,
+  `GetMessage`, `IsCurrentSource`, `IsExceptionalExecution`) and
+  `M2EXCEPTION`;
+- runtime handler model (handler stack / `setjmp`-`longjmp` or
+  equivalent), re-raise on unhandled;
+- `lazyunique` additionally needs ISO `UNIQUE`.
+
+Design the handler model first; then implement with trap tests.
+
+## 3. Multi-dimensional open arrays — 8 files
+
+`unbounded`, `unbounded2/3/4/6/8`, `array9`, `adrunbounded3`.  **Do not
+just accept them**: V3 uses a descriptor per level; gm2 passes a flat
+block with strides, and the corpus checks `ADR(m) = ADR(m[0])` and flat
+`SIZE`.  Decide on an ABI (flat/strided descriptor) before implementing;
+otherwise leave parked.  `unbounded5` is a declaration-order case, not
+this feature.
+
+## 4. Runtime range checks — done, follow-ups
+
+`Lower.CheckSub` covers assignment, value actuals, `RETURN` and
+`INC`/`DEC`; the `FOR` final increment is exempt.  Possible follow-ups:
+
+- `LONGINT`/`CARDINAL` subranges (currently skipped);
+- `FOR` control variables (decide whether to range-check the initial
+  bound only, as now);
+- trap tests for CHAR/enum subranges (currently integer).
+
+## 5. Library folders / separate compilation — deferred plans
+
+- `docs/plan-separate-compilation.md` — stable symbols, per-unit
+  objects, init order, linker; and the appendix on dialect folders.
+- Library-folder layout (`lib/pim`, `lib/iso`, `lib/m2r10`, shared
+  `runtime/syslib`) is a low-risk build change, to do after the
+  compiler language work; no need to mix dialects in one session.
+
+## 6. Corpus leftovers (classify first)
+
+`ptrarray3` (open-array actual), `unbounded7` (2-D actual for
+`ARRAY OF BYTE`), `adraddress` (ADDRESS/pointer compare), `proc` /
+`shift3` / `shift4` (decl-order), `constprocedure`/`constvec3`/
+`conststrarray` (mostly ordered decls).  Park gm2 extensions, wide sets
+(`settest1/3`) and `CHAR.mod` as before.
+
+## Gates for every step
+
+```sh
+cd compiler && ./build.sh && ./run_tests.sh          # 262/262
+cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
+tools/v3-corpus/corpus.sh                            # 511 OK, 0 crash
+```
+
+Update `STATUS.md`, `features.md`, `gaps/`, the comparison table and a
+session summary; commit with a `v3-*` tag.  Do not push without asking.
+
+## Resume
+
+```sh
+cd .../m2compiler-V3
+git checkout master
+cd compiler && ./build.sh && ./run_tests.sh          # 262/262
+cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
+tools/v3-corpus/corpus.sh                            # 511 OK, 0 crash
+```
+
+**Recommendation:** implement `PACKEDSET` properly (it is the only
+small, self-contained language feature left in the current handoff), or
+take the ISO exceptions design if you want a larger block.  Leave
+multi-dimensional open arrays and library/separate-compilation work for
+their own sessions.

+ 60 - 0
docs/summary_session-2026-10-23.md

@@ -0,0 +1,60 @@
+# Session 2026-10-23 — continuation: range checks; PACKEDSET inspection
+
+Branch **`master`**.  Continues `summary_session-2026-10-22.md` from the
+2026-10-22 stop point (`v3-smallfix`).
+
+## Numbers
+
+| gate | start | end |
+| --- | --- | --- |
+| suite (`compiler/run_tests.sh`) | 259/259 | **262/262** |
+| fixpoint (`bootstrap/fixpoint.sh`) | OK (4,028,447 B) | **OK (4,032,793 B)** |
+| corpus (`tools/v3-corpus/corpus.sh`) | 511/612 | **511/612, 0 crashes** |
+
+## What landed
+
+### Runtime subrange range checks — `Lower` + `QbeGen.CheckRange`
+
+V3 accepted base-typed values into CHAR/enum subranges but emitted no
+runtime check.  `Lower.CheckSub` now traps (abort) when the value is
+outside the destination subrange on:
+
+- assignment (scalar, field or array element);
+- a value actual whose formal is a subrange;
+- `RETURN` whose function result is a subrange;
+- `INC`/`DEC` on a subrange.
+
+The **post-increment of a `FOR` control variable is exempt**: the final
+successor of a loop over a full subrange (`FOR x := 0 TO 3` with
+`x: [0..3]`) may legitimately exceed the upper bound.  `LONGINT`
+subranges are not checked yet.
+
+Regressions: `t_trap_range` (assignment), `t_trap_range_arg` (actual),
+`t_trap_range_ret` (`RETURN`); `t_subrange` remains the in-range case.
+
+### PACKEDSET — inspected, parked
+
+The handoff suggested starting with `PACKEDSET`.  Inspection of
+`onebyte*` shows it is **not** safe to alias to `SET`:
+
+- `SIZE(PACKEDSET) = SIZE(BYTE) = 1` is asserted;
+- `ORD(set)` is asserted (e.g. `ORD(si) = 2`, `ORD(se) = 32`);
+- `onebyte3` uses an `ARRAY OF PACKEDSET` and checks neighbouring bytes.
+
+A faithful implementation needs a 1/2/4-byte packed representation and
+packed set operations, not just a parser alias.  It is parked in
+`docs/handoff-2026-10-23-next.md` / `docs/gaps/README.md`.  Corpus
+stays at 511.
+
+## Commits
+
+| commit | tag | work |
+| --- | --- | --- |
+| `54d84b9` | `v3-rangechecks` | runtime subrange range checks (+3 trap tests) |
+
+## Remaining
+
+See `docs/handoff-2026-10-23-next.md`.  The next candidates are
+`PACKEDSET` (with a real representation), ISO exceptions (dedicated
+session), multi-dimensional open arrays (ABI decision), and the
+library-folder / separate-compilation plans (both deferred).