summary_step7.md 2.3 KB

Step 7 — Module procedures with parameters and functions (uncommitted)

120/120 tests green (112 regressions + 5 run + 5 rejection, minus 2 retired), mc64 boot + example green, Showcase still 157.

Goal

Finish local-MODULE procedures: value/VAR parameters (incl. open-array formals), functions returning values usable in expressions, bare M.P; calls, and single-error cascades for bad module calls.

What was built

  • SymTab: procs[] survives scope pops, so four by-number accessors (ProcValid, ProcNParByNum, ParamTypeByNum, ParamIsVarByNum, ProcRetByNum) keep exported procs callable after ExitModule.
  • MGen: ActFrame gained byNum/num; new ActBeginNum/ActEndNum (global ED call — module procs never need the display); ActValue checks formals through ActFormalType/ActFormalIsVar so value, VAR and open-array actuals share one path.
  • M2c.atg: CallTail module path now takes real actuals (arity/type via 233), rejects proper procs in expressions, routes unknown exports through the module path; Fact synthesizes the module-function return type; AssignOrCall bare branch handles M.P; (with Drop for functions).
  • run_tests.sh: step-7 sections added.

Tests — 120/120 (112 + 5 + 5 − 2 retired)

5 run: m_param 15 (value param), m_varpar 15 (VAR param), m_func 45 (function in expr + M.Get()/M.Get; statements with side-effect count), m_open 10 (open-array formal, HIGH), m_bare 2 (M.Inc; without parens). 5 rejections, each exactly one error: m_bad_arity, m_bad_mactual, m_bad_mvar (module var as VAR actual), m_bad_mfunc (proper proc in expression) → 233; m_bad_nope → 201. Retired: m_bad_param, m_bad_func — valid programs now (deleted).

Bugs found and fixed

  1. M.Nope() double-reported (201 + 233): unknown exports left lx empty so CallTail fell into the regular path. Unknown exports now CopyName into lx (module path) and stay quiet there — the 201 was already reported, mirroring how unknown plain names pass ActEnd quietly. Same treatment for bare M.Nope;.

Known limits (deferred)

Type exports, DEFINITION/IMPLEMENTATION split, module BEGIN bodies, VAR actuals with tails (M.cnt as VAR actual → 233), open-to-open actuals, value composite params, forward-declared module procs (untested).