Explorar el Código

docs: 2026-10-22 stop point — comparison, summary, next plan

Final comparison-table state (v3-smallfix; 259/259, fixpoint OK
4,028,447 bytes, corpus 511/612), the session summary with a stop-point
section, and docs/handoff-2026-10-22-next.md (PACKEDSET, ISO
exceptions, multi-dimensional open arrays/ABI, range checks; gates).
INDEX points at the new handoff.
Eric Streit hace 18 horas
padre
commit
c2664ac239

+ 6 - 3
docs/INDEX.md

@@ -6,14 +6,17 @@ bisecting *why* a decision was made, not for reading end-to-end).
 
 ## Start here
 
-- **`handoff-2026-10-19-next.md`** — next-session plan (P1–P5 status,
-  the ASTDUMP root cause, gates).
+- **`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-19-next.md`** — previous plan (P1–P5 status, the
+  ASTDUMP root cause).
 - **`STATUS.md`** — current state, architecture, conformance policy,
   what remains.
 - **`plan.md`** — the phased plan (Blaise-adapted).
 - **`features.md`** — the feature list.
 - **`comparison-PIM4-gm2-V3.md`** — PIM4 / GNU Modula-2 / V3 feature
-  comparison (2026-10-22; V3 at `v3-proc-types`).
+  comparison (2026-10-22; V3 at `v3-smallfix`).
 - **`analysis_gaps.md`** — language gaps + corpus notes.
 - **`gaps/README.md`** — minimal reproducers, one per unsupported gap,
   and the gm2-extension policy.

+ 10 - 9
docs/STATUS.md

@@ -156,15 +156,16 @@ declarations still work (`t_fwdproc`, `t_fwdok`).
 1. **Corpus** — the 2026-10-22 triage fixed four conforming clusters
    (+18 sources: PIM/ISO `ARRAY [..], [..] OF`, typed CHAR/enum
    subranges, ordinal `FOR`, ISO empty string `""`/`''` as CHAR), added
-   real **libc prototypes** (+6: `printf`/`snprintf` are varargs
-   functions, `malloc`/`memset`/`write`/… typed; the remaining libc
-   importers fail later for other reasons), **ISO SYSTEM sized
-   types + qualified `SYSTEM`** (+8), and **ISO procedure-type syntax**
-   (+4: comma-separated unnamed params, `PROC` result).  The remaining `LANG` entries are
-   mostly: **declaration order** cases V3 rejects by policy
-   (`docs/gaps/`); ISO exceptions/`PACKEDSET`; multi-dimensional open
-   arrays (representation, see below); and gm2-only modules
-   (`M2RTS`/`Builtins`/…).  See `docs/analysis_gaps.md`.
+   real **libc prototypes** (+6), **ISO SYSTEM sized types + qualified
+   `SYSTEM`** (+8), **ISO procedure-type syntax** (+4), **ISO
+   `SysClock`** (+2), and **small fixes** (+6: string-constant folding,
+   `ORD(bool)` in CONST, `HIGH`/`LEN` of string CONSTs, ordinal
+   `INC`/`DEC`, leading CASE `|`, `__FUNCTION__`).  Corpus is **511/612**
+   at the stop point.  The remaining `LANG` entries are mostly:
+   **declaration order** cases V3 rejects by policy (`docs/gaps/`); ISO
+   exceptions/`PACKEDSET`; multi-dimensional open arrays
+   (representation, see `handoff-2026-10-22-next.md`); and gm2-only
+   extensions.  See `docs/analysis_gaps.md`.
 2. ~~**The size-sensitive V3 miscompile**~~ — **root-caused and fixed**
    (2026-10-19; see `docs/summary_l3_selfhost_fix.md`).  It was never
    size-sensitive: the fixpoint gate matched the literal string

+ 6 - 5
docs/comparison-PIM4-gm2-V3.md

@@ -1,7 +1,8 @@
 # PIM4 vs GNU Modula-2 vs V3 — feature comparison
 
-**Date:** 2026-10-22 · **V3 state:** `v3-smallfix` (suite 259/259,
-self-hosting fixpoint OK 4,028,447 bytes, corpus 511/612, 0 crashes).
+**Date:** 2026-10-22 · **V3 final state:** `v3-smallfix` (suite
+259/259, self-hosting fixpoint OK 4,028,447 bytes, corpus 511/612,
+0 crashes).
 
 **Scope.** **PIM4** is Wirth's *Programming in Modula-2*, 4th edition
 (the language specification, not a compiler).  **GNU Modula-2 (gm2)** is
@@ -46,7 +47,7 @@ are listed at the end.
 | `INTEGER`/`CARDINAL`/`SHORTINT`/`LONGINT`, `REAL`/`LONGREAL`, `BOOLEAN`, `CHAR` | ✅ | ✅ | ✅ |
 | Subranges | ✅ | ✅ | ✅ (typed CHAR/enum subranges since 2026-10-22) |
 | Enumerations | ✅ | ✅ | ✅ |
-| Sets (`SET OF`) | ✅ any finite ordinal (impl. limit) | ✅ | 🔄 bool/char/enum/small-int subrange; span ≤ 65536; no `SET OF CARDINAL` |
+| Sets (`SET OF`) | ✅ any finite ordinal (impl. limit) | ✅ | 🔄 bool/char/byte/16-bit/enum/small-int subrange; span ≤ 65536; no `SET OF CARDINAL` |
 | `PACKEDSET` | ❌ (ISO) | ✅ | ❌ |
 | Fixed arrays, multi-dimensional | ✅ `ARRAY [a], [b] OF` | ✅ | ✅ both `[a], [b]` and `[a, b]` |
 | Open arrays (1-D) | ✅ | ✅ | ✅ |
@@ -116,8 +117,8 @@ are listed at the end.
   prototypes).  Its hard gaps are the large ISO features (**exceptions,
   complex arithmetic, `PACKEDSET`, finalization/protection,
   multi-dimensional open arrays, ISO OO**) and parts of the **word
-  model** (`SHORTREAL`, `REAL` width, 16-bit types), plus a **65536-bit
-  set span limit**.
+  model** (`SHORTREAL`, `REAL` width), plus a **65536-bit set span
+  limit**.
 
 ## V3-specific deviations and limits
 

+ 123 - 0
docs/handoff-2026-10-22-next.md

@@ -0,0 +1,123 @@
+# Next session — plan (from 2026-10-22 stop point)
+
+**Branch:** `master` (tree clean at the stop point).  **Feature state:**
+`v3-smallfix`.  **Gates:** suite **259/259**, fixpoint **OK
+(4,028,447 bytes)**, corpus **511/612, 0 crashes**.
+
+Read first: `docs/STATUS.md` (live state), `docs/features.md`,
+`docs/gaps/README.md` (policy + reproducers), and
+`docs/summary_session-2026-10-22.md` (what the last session did).
+
+## Policy reminder
+
+V3 follows **PIM/ISO Modula-2**, not gm2's leniencies.  Declaration
+before use is required for data; the only forward type reference is a
+`POINTER`'s base.  gm2 compatibility is accepted only where explicitly
+chosen and documented (`docs/gaps/README.md`).  The corpus is gm2's
+testsuite, so `LANG` includes deliberate rejections; classify before
+fixing.
+
+## 1. `PACKEDSET` — 3 corpus files (`onebyte`, `onebyte2`, `onebyte3`)
+
+ISO 10514-1 has `PACKEDSET OF <ordinal>`; XDS states that the standard
+does not mandate a representation and treats sets/packedsets the same.
+Options:
+
+- **Minimal:** parse `PACKEDSET` as `SET` (the XDS interpretation) and
+  document that the representation is not bit-packed.  This compiles the
+  three files but `onebyte*` may test `SIZE`/bit layout — inspect first.
+- **Faithful:** add a packed representation (1/2/4-byte masks), which
+  means new set ops at byte granularity in `QbeGen` and type sizing.
+
+Suggested decision: inspect `onebyte*`; if they only use set operations
+(not `SIZE`-sensitive), map to `SET` and document.  Add a regression.
+
+## 2. ISO exceptions — 7 corpus files (`except2/4/5/7/8/9`, `lazyunique`)
+
+This is a **feature**, not a parser tweak:
+
+- `EXCEPT` / `RETRY` after a normal statement sequence (procedures and
+  module bodies);
+- `EXCEPTIONS` (AllocateSource/RAISE/CurrentNumber/GetMessage/
+  IsCurrentSource/IsExceptionalExecution) and `M2EXCEPTION`;
+- runtime support (handler stack / `setjmp`-`longjmp` or equivalent);
+- `lazyunique` also needs ISO `UNIQUE` module support.
+
+Design a minimal handler model first (one active handler per procedure,
+exception state per coroutine, re-raise on unhandled), then implement.
+Budget a dedicated session; do not start it as a "small fix".
+
+## 3. Multi-dimensional open arrays — 8 corpus files
+
+`unbounded`, `unbounded2/3/4/6/8`, `array9`, `adrunbounded3`.
+**Do not just accept them**: V3 represents each array level as its own
+descriptor, while gm2 passes a flat block with strides.  The corpus
+files check `ADR(m) = ADR(m[0]) = ADR(m[0][0])` and flat `SIZE` values,
+so compiling them would silently miscompile.
+
+Next step is an **ABI decision**:
+
+- keep the nested-descriptor model and add a flat/strided open-array
+  descriptor for multi-dimensional formals (real work), or
+- document the limitation and leave this bucket parked.
+
+`unbounded5` is different: a type declared after its use (decl-order
+gap), not this feature.
+
+## 4. Runtime subrange range checks — conformance
+
+V3 accepts base-typed values into CHAR/enum subranges (2026-10-22) but
+emits no runtime range check, and is already lenient for the integer
+family.  Add `QbeGen.CheckRange` on assignment / parameter binding /
+`RETURN` where the destination is a subrange, with an `abort` trap; add
+trap tests (like `t_trap_index`).  This is the main remaining
+conformance difference from the subrange work.
+
+## 5. Optional / larger
+
+- **ISO 10514-3 OO** vs the Clarion-form `CLASS`.  Large; only if OO
+  conformance becomes a goal.
+- **A real `stdlib/libc.def`** instead of the built-in prototype table.
+  Not needed for the corpus; useful for user code (`DEFINITION MODULE
+  FOR "C"`, varargs, `SYSTEM.CSIZE_T`).
+- **Small corpus leftovers** (classify first): `ptrarray3` (open-array
+  actual), `unbounded7` (2-D actual for `ARRAY OF BYTE`), `adraddress`
+  (ADDRESS/pointer compare), `proc` (decl-order), `shift3/4`
+  (decl-order), `constprocedure`/`constvec3`/`conststrarray` (mostly
+  ordered decls).
+
+## Known non-targets / parked
+
+- gm2 extensions: `ASM`, address arithmetic, absolute `VAR [addr]`,
+  `666B`/`012H` literals, `SHORTREAL` as 32-bit, char arithmetic,
+  set ordering (`largeset5`), module named `CHAR`.
+- decl-order cases (gaps 01–06, 19–21) — V3 rejects them by policy.
+- wide sets (`settest1/3`): implementation limit (span > 65536).
+- `CHAR.mod`: a module named `CHAR` collides with the pervasive type.
+
+## Gates for every step
+
+```sh
+cd compiler && ./build.sh && ./run_tests.sh          # must stay 100%
+cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
+tools/v3-corpus/corpus.sh                            # record OK/CRASH
+```
+
+Then update `docs/STATUS.md`, `docs/features.md`, `docs/gaps/` and the
+comparison table, and commit with a `v3-*` tag.  Do not push without
+asking; tags are immutable per feature.
+
+## Resume
+
+```sh
+cd .../m2compiler-V3
+git checkout master
+cd compiler && ./build.sh && ./run_tests.sh          # 259/259
+cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
+tools/v3-corpus/corpus.sh                            # 511 OK, 0 crash
+```
+
+**Recommendation:** start with `PACKEDSET` (after inspecting
+`onebyte*`), then the subrange range checks; reserve a whole session for
+ISO exceptions, and make an explicit ABI decision before touching
+multi-dimensional open arrays.

+ 13 - 3
docs/summary_session-2026-10-22.md

@@ -218,9 +218,11 @@ IMPORT` stays permissive (its names are global predefs or keywords).
 
 Added the ISO/gm2 names: `WORD8/16/32/64`, `BITSET8/16/32`,
 `REAL32/64/128`, `COMPLEX32/64/128`, `CSIZE_T`/`CSSIZE_T`/`COFF_T`,
-and `BITSPERLOC`/`LOCSPERWORD`/`LOCSPERBYTE`.  V3 keeps its 32-bit
-word model, so the narrow integer/word names share `INTEGER`/
-`CARDINAL` and `COMPLEX*` is a `REAL` placeholder.  Corpus **+8**:
+and `BITSPERLOC`/`LOCSPERWORD`/`LOCSPERBYTE`.  At this step V3 still
+had a 32-bit word model, so the narrow integer/word names shared
+`INTEGER`/`CARDINAL`; later in the session `BYTE`/`SYSTEM` 8-bit names
+and `WORD16`/`CARDINAL16`/`INTEGER16` became true 8/16-bit storage (see
+below).  `COMPLEX*` remains a `REAL` placeholder.  Corpus **+8**:
 `compsize`, `int8field`, `returnrecord`, `printsize`, `testgeneric`,
 `testgeneric2/3/4`.  Regression `t_system`.
 
@@ -249,3 +251,11 @@ git push origin master v3-smallfix
 # only if you want the moving tag advanced on the remote too:
 git push --force origin refs/tags/v3-session-2026-10-22
 ```
+
+## Stop point
+
+Session stopped here by request.  Final gates: suite **259/259**,
+fixpoint **OK (4,028,447 bytes)**, corpus **511/612, 0 crashes**.
+Feature tag `v3-smallfix`; the session summary is tagged
+`v3-session-2026-10-22-end`.  The next-session plan is
+`docs/handoff-2026-10-22-next.md`.