summary_step9.md 2.3 KB

Step 9 — Type exports + tailed whole-copy fix (uncommitted)

137/137 tests green (127 + 7 run + 3 rejection), mc64 boot + example green, Showcase still 157, new Showcase2 (type exports, module/field/row copy, enum literals, VAR tails) prints 83 as hand-computed.

Goal

Export TYPEs from local MODULEs (M.T in every type position) and repair what the first probes exposed: whole-copy into a composite destination with tails silently emitted a single-slot store.

What was built

  • M2c.atg QualIdent: a KindModule head no longer 221s; the "." tail resolves through ExpKind/ExpType — KindType accepted, unknown → 201, non-type → 221. One edit covers all positions (SimpleType delegates: VAR, params, return types, POINTER / ARRAY / SET / record-field element types), since export type indexes are global and persistent.
  • M2c.atg AssignOrCall setup: a second pushedDst arm for tailed composite destinations (M.G := p, r.b := q, mat[1] := row, p^ := q) whose address is already on the stack — same copy_block path, no extra push. Scalar tails are excluded by the Array/Record class check, so M.cnt := 10 is untouched.
  • Bonus, free of charge: exported enum literals (EXPORT Red...) ride the KindConst path — c := M.Green, M.Red CASE labels work.
  • run_tests.sh: step-9 sections added.

Tests — 137/137 (127 + 7 + 3)

7 run: t_mint 5 (alias), t_mrec 30 (record whole-copy both directions through M.Origin), t_marr 18 (VAR M.Vec param + whole copy), t_mptr 7 (M.PNode + NEW), t_menum 11 (literals + qualified CASE labels), c_fcopy 5 (field-destination copy), c_row 15 (matrix-row copy). 3 rejections, each exactly one error: t_bad_mtype 221 (M.cnt as a type), t_bad_mghost 201, t_bad_mmod 230 (bare M).

Bugs found and fixed

  1. M.Origin := p (same type!) silently stored one slot (584 instead of 30): tailed composite destinations fell into the scalar StoreIndir0 emission. Same latent bug in plain field tails (r2.b := r1.b → 584, pre-existing since step 5 — old copy tests only used plain destinations). Fixed by the pushedDst extension; 127/127 stayed green.

Known limits (deferred)

DEFINITION/IMPLEMENTATION split, module BEGIN bodies, WITH-field VAR actuals, CHAR/BOOLEAN tails as VAR actuals, open-to-open.