summary_dlist-showcase-2026-10-16.md 2.6 KB

Session summary — DList showcase and generics limitation fixes (2026-10-16)

Branch resolve-check, tree clean. Suite 219/219; fixpoint OK (3,714,376 bytes); corpus 372 OK / 0 crash.

Tags this arc: v3-showcase23, v3-generics-limitations-fixed.

The showcase

showcase23 is a generic doubly linked list: DList (T : TYPE) with Node/List records, Init/Append/Prepend/Count/Get/ Sum/Reverse/ForEach, instantiated as IntList = DList(INTEGER). It exercises a type parameter, arithmetic over it (Sum), and a procedure parameter (ForEach with an imported visitor):

list: 5 10 20
sum=35          (Sum over T)
foreach=35      (ForEach + imported visitor procedure)
reversed: 20 10 5

Files: showcase23lib.def/.mod (generic), showcase23int.def/.mod (refinement), showcase23vis.def/.mod (the visitor), showcase23.mod (the program). Wired as expect_run_files_out Showcase23 35 "list: 5 10 20".

Bug fixed — global record data size (general)

QbeGen.RecItems emitted w 0 (4 bytes) for every scalar record field, including pointers/LONGINT/proc (8 bytes), so a global of such a record was under-sized and later globals clobbered its tail (List.count read as 0). Now emits l 0 for ClPtr/ClLong/ClProc. Regression t_recptr.

Limitations fixed (65f331e)

  1. Arithmetic/relations over a type formal — the expression checks (ArithCheck/RelCheck/BoolCheck/OrdCheck/InCheck/EqCheck) now skip on Resolve(x) = InvalidType (as Assignable already did), so an unbound formal is unknown in the template and checked normally once bound. (Sum over T works.)
  2. Proc-typed formals in a DEF/IMPL pair — FormalOk compares two FProc formals structurally (ProcTypesOk), like open arrays, instead of by TypeIndex. No more false 235.
  3. Imported procedure used as a value — LowerProcAddr falls back to SymTab.SymBase(nm), so f := Visitor.Add resolves to the code address (was 0). (t_importproc.)

Verify

cd .../m2compiler-V3/compiler
./M2 ../stdlib/sysio.def ../stdlib/sysio.mod \
    tests/showcase23lib.def tests/showcase23lib.mod \
    tests/showcase23int.def tests/showcase23int.mod \
    tests/showcase23vis.def tests/showcase23vis.mod tests/showcase23.mod
# -> list: 5 10 20 / sum=35 / foreach=35 / reversed: 20 10 5, exit 35

Standing generics status

Type/value/procedure parameters, constraints (ORDINAL/INTEGER/REAL/POINTER/SCALAR), nested generics, and generic classes (via generic modules) all work; see docs/summary_generics-closed-2026-10-16.md.