On this page

0048: Checked teaching programs

Context

Teaching diagnostics need actual corrected programs and a small JSON surface. Existing JSON goldens and compiler phase messages must remain byte-identical.

Decision

Embed two TSV teaching tables alongside the diagnostics registry. Each active code has a wrong program and a complete corrected program. Tests check exact single-code failure and successful correction through the shared front end. The instance-limit example references the existing generated stress fixture; human explain expands it, so the displayed program is the tested one.

Human explain retains meaning and repair advice and adds both programs. JSON explain contains code and complete corrected source only. Ordinary diagnostics retain their existing shape; their code is the lookup key for teaching content. Enforce 540-byte JSON lines (ceil(bytes / 3.6) <= 150) across all diagnostic fixtures and explanation codes. No backend or execution semantics change.

Alternatives considered

Consequences

New diagnostic codes require a verified teaching pair. Resource-limit examples can reuse stress fixtures. TSV newline encoding is deliberately minimal; future examples needing literal backslash-n in source need an explicit encoding change.