handoff-2026-10-23-next.md 4.7 KB

Next session — plan (from 2026-10-23)

Branch: master. Feature state: v3-packedset. Gates: suite 263/263, fixpoint OK (4,075,853 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 — done (spans ≤ 32 bits)

Implemented 2026-10-23: 1/2/4-byte storage, SIZE/ORD, INCL/EXCL/ IN, assignment, set operations, packed arrays/records/parameters. Wider packed sets are a loud 230 implementation limit. Regression t_packedset.

The corpus files onebyte, onebyte2, onebyte3 still do not compile, but the blocker is earlier: they use the module variable r inside assert before its declaration (declaration order, rejected by policy). With r moved before the procedure they compile and run. Do not relax declaration order for this corpus case.

2. ISO exceptions — design first (docs/design-exceptions.md)

A dedicated feature session, not a small fix. Start with the design in docs/design-exceptions.md (grammar/AST, handler stack, sigsetjmp/ siglongjmp codegen, EXCEPTIONS/M2EXCEPTION, trap mapping, tests):

  • EXCEPT / RETRY after a normal statement sequence (procedures, implementation/program/local module bodies);
  • EXCEPTIONS (AllocateSource, RAISE, CurrentNumber, GetMessage, IsCurrentSource, IsExceptionalExecution) and M2EXCEPTION;
  • runtime handler model (handler stack + saved state, sigsetjmp/ siglongjmp, signal-to-language-exception mapping), re-raise on unhandled;
  • SYSTEM.THROW (gm2 extension) for except5/except7.

Corpus reality: lazyunique is the genuine +1 (no declaration-order issue). except2/4/5/7/8/9 declare ip after the procedures and still hit the strict declaration-order rule, like onebyte*; keep moved-ip copies as semantic tests but do not count them in the corpus until the policy changes. lazyunique also needs no EXCEPTIONS import, so the corpus count target is 512, not 518.

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

cd compiler && ./build.sh && ./run_tests.sh          # 263/263
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

cd .../m2compiler-V3
git checkout master
cd compiler && ./build.sh && ./run_tests.sh          # 263/263
cd .. && TMP="$PWD/.scratch/fixpoint" ./bootstrap/fixpoint.sh
tools/v3-corpus/corpus.sh                            # 511 OK, 0 crash

Recommendation: start the ISO exceptions design (the largest remaining language feature), or take the multi-dimensional-open-array ABI decision if you prefer an ABI task. Library folders and separate compilation remain deferred (docs/plan-separate-compilation.md).