# Session save — 2026-09-24 (m2compiler-V3) HEAD `dd7767c`. Suite **110/110**, build warning-free, tree clean, no remote (`git.txt` untracked). ## Landed today | Tag | Commit | What | |---|---|---| | `v3-fix-fileio-null` | `035d9ef` | shim file routines are NULL-handle safe (failed open no longer SIGSEGVs; `t_badfile`) | | `m2make-1.0` (+`-summary`) | `2f243ed`/`863a5ec` | `tools/m2make`: build-order front-end for M2/gm2 (topo-sort imports, incremental); `FileIO` argv starts at 1; tests 18/18 | | `v3-fix-nested-arrays` | `f019a17` | `Fact` no longer double-loads nested-array designators (row → open-array actual no longer SIGSEGVs); `t_nestidx` | | `v3-proctypes` | `439d955` | **procedure types + indirect calls** (see below); `t_proctype` | | `v3-m2s-clean` | `dd7767c` | **`M2S` compiles clean under V3** + compatibility additions; `t_compat` | Later tags may not all appear in `git tag | tail` (alphabetical); use `git tag | grep -E 'm2make|proctypes|m2s|nested|fileio'`. ## Key results - **Self-compilation:** `SymTab`, `QbeGen` and **`M2S`** compile clean under V3 (0 errors). - **Procedure types** (step 3): `PROCEDURE (…) : T` types (named *and* type-only param lists), procedure-typed variables, assignment of a procedure name, indirect calls (`call %ptr(l 0, …)`). Static link is always `0` (nested procedure values / static links are not yet supported). Implementation: `SymTab` `FProc` descriptor + `ProcTypeOf` + structural compatibility; `QbeGen` `ProcAddr`, `CallBeginInd`/`CallEnd`; grammar `ProcType`, proc-value in `Fact`, proc-type path in `ArgList`/`ActParam`. - **Compatibility additions** V3 now accepts to compile CR's *generated* scanner tables: `&` (AND), `~` (NOT), `LENGTH` (alias of `LEN`), `ORDL` (alias of `ORD`), octal char literals (`0C` …), empty `THEN`/`ELSE`/loop bodies, and `CAP` (new builtin). These come from the CR binary's built-in templates, not our `scanner.frm`. - **Latent bug fixed:** `ABS` (and `CAP`) computed a result temp that `Fact` never copied back to `q`; both now `CopyOp(qa, q)`. ## Remaining self-hosting gaps - **`M2P.mod`** (Coco/R parser): 107 errors, 102 of them `undeclared identifier` = **within-module forward procedure calls** in CR's recursive-descent parser (gm2 hoists; ISO wants declaration-before-use or `FORWARD`). Also `BITSET{…}` constructors and `symSet[0, 0]` nested-array assignment. - **`M2.mod`** (driver): needs nested procedure values with static links (`Error := StoreError`, `StoreError` nested in `ListHandler`). - Host `FileIO` caps at 16 open files — compiling all ~16 modules in one session exceeds it; split sessions or raise the cap. - Then: cross-stage `FileIO` selection and `bootstrap/fixpoint.sh` (Stage1 gm2 → Stage2 V3 → Stage3 V3, byte-identical `.ssa`), plausibly driven by `M2make`. ## Resume ```sh cd /home/eric/Projets/Projets-Modula2/MyWork/m2compiler-V3/compiler ./build.sh && ./run_tests.sh # expect 110/110 # M2S clean check (needs the stub program): printf 'MODULE Gap;\nIMPORT SymTab;\nVAR ExitCode : INTEGER;\nBEGIN ExitCode := 0 END Gap.\n' > /tmp/gap.mod ./M2 ../stdlib/storage.def ../stdlib/storage.mod \ ../runtime/syslib/SysShim.def ../runtime/syslib/SysShim.mod \ ../runtime/syslib/FileIO.def ../runtime/syslib/FileIO.mod \ src/M2S.def src/M2S.mod /tmp/gap.mod # M2make: cd ../tools/m2make && ./build_gm2.sh && ./build_m2.sh && ./tests/run_tests.sh ``` ## Docs added today `docs/summary_fix-fileio-null.md`, `docs/summary_m2make.md`, `docs/summary_fix-nested-arrays.md`, `docs/summary_proctypes.md`, `docs/summary_m2s-clean.md`.