Design decisions

190. Diagnostic codes: one per rule, held to the catalogue by a test (2026-11-21)

  • Decision. A mixed comparison chain is E0111, a recursive var lambda E0406, a let passed as mut E0403; traps get their catalogued codes (R0102 D(x) outside D, R0201 range store, R0401 assertion, R0501 bad token or input ended, R0502 input outside its read contract, R0601 stack), leaving R0001 for the rest. E0404 and E9998 are retired (never emitted, never reused); E0306 is reserved (position arithmetic reports as E0309 and lint L0101). crates/cpl-cli/tests/catalogue.rs checks every defined code is catalogued, every code marked (0.3)/retired/reserved is undefined, and every emitted code's registry trigger yields exactly that code and its fix runs clean; registry entries carry input for run triggers. The sink drops a second error at the exact span of an earlier one, whatever its code.
  • Why. Stream 8: "one diagnostic per root cause" and stable codes need a check that fails when a code drifts. Running out of input is the same mistake as a wrong token (the format was misread), so it shares R0501.
  • Reverse. Recode in crates/cpl-diag/src/lib.rs and Trap::code, then update the table; the test says what else moves.