Procházet zdrojové kódy

docs: generics status 2026-10-15 (inc2 scope + multi-formal link failure)

Eric Streit před 2 dny
rodič
revize
331b308391
1 změnil soubory, kde provedl 54 přidání a 0 odebrání
  1. 54 0
      docs/summary_generics-2026-10-15.md

+ 54 - 0
docs/summary_generics-2026-10-15.md

@@ -0,0 +1,54 @@
+# Generics status — 2026-10-15
+
+Branch **`resolve-check`** (contains `v3-generics-inc2`, 19 commits back).
+Design: `docs/analysis_generics.md`; inc2 record:
+`docs/summary_generics-inc2.md`. Suite **196/196**, incl.
+`GenericProg` (single-formal `Ident(INTEGER)`, exit 42).
+
+## What works
+
+ISO 10514-2 form: `GENERIC DEFINITION/IMPLEMENTATION MODULE M(T :
+TYPE)` plus refinement `DEFINITION MODULE X = M(actual)`. A refinement
+instantiates by **re-parsing the generic's source** with the formals
+bound to the actuals (`SymTab.EnterTypeParamBound`, `Reenter`; driver
+registry maps generic name → file; the abstract template is never
+emitted). Re-verified live: `FROM IntId IMPORT Id; Id(42)` → exit 42.
+
+## Fresh finding: multiple formals parse but do not link
+
+Probed 2026-10-15 (not in the suite):
+
+```modula2
+GENERIC DEFINITION MODULE Pair (T : TYPE; U : TYPE);
+PROCEDURE First(x : T; y : U) : T; ...
+DEFINITION MODULE IntChar = Pair(INTEGER, CHAR); ...
+```
+
+Compiles (`Parsed correctly`) but **fails at link**: undefined
+`First_4`. The emitted `.ssa` references `First_4` once (call site) and
+defines no such function — the implementation unit's instantiation
+drops (or misnames) the body when there is more than one formal. The
+inc2 doc says multiple formals are "threaded but only a single `T` is
+exercised": threading covers parse, not emit. Repro files (throwaway,
+not committed): `/tmp/opencode/g2*.mod`.
+
+## Still open (unchanged from inc2)
+
+- Fix multi-formal instantiation (bug in shipped scope — sensible first
+  step before new features).
+- Increment 3: const/procedure parameters, constraints.
+- `GENERIC CLASS`; generics with a program module.
+- Instance dedup (each refinement re-instantiates today).
+- Ordering rule stands: refinement file after the generic's file,
+  generic def before its impl.
+
+## Resume
+
+```sh
+cd .../m2compiler-V3/compiler
+./M2 tests/g_ident.def tests/g_ident.mod tests/g_intid.def \
+  tests/g_intid.mod tests/g_prog.mod   # GenericProg session
+```
+
+Multi-formal repro: rebuild `/tmp/opencode/g2*.mod` per §"Fresh
+finding" above, then `qbe` + `cc` to observe the link failure.