iter 22-tidy.7: journal entry

This commit is contained in:
2026-05-10 05:18:46 +02:00
parent dafdf17f72
commit 5676a99bfa
+65
View File
@@ -12365,3 +12365,68 @@ The inline path is unreachable for the surface forms emitted by
the parser today (forall only appears at fn-signature top level),
so the gap is dormant. If a future feature carries a forall in
inline position with constraints, this is the place to extend.
## 2026-05-10 — Iteration 22-tidy.7: strict-clause helper consolidation
Closing the queued observation from 22-tidy.5: the
duplicate-clause check pattern had grown to 17 inline blocks
(10 from 22b.4a + 8 from 22-tidy.5; the JOURNAL entry's "18 sites"
was an off-by-one) of identical 12-line shape across
`parse_data`, `parse_fn`, `parse_const`, `parse_class`,
`parse_class_method`, `parse_instance`, `parse_instance_method`.
17 × 12 LOC of textual duplication is past the tipping point;
this iter consolidates them.
Introduced one private method
`Parser::duplicate_clause_err(&self, production: &'static str,
subject: &str, clause: &'static str) -> ParseError` that captures
the `pos` lookup, formats the canonical
`"<subject> has duplicate `(<clause> ...)` clause"` message, and
returns the `ParseError::Production` shape. All 17 inline blocks
reduced to one-line calls; net -99 LOC on `parse.rs` (31 ins,
130 del).
Three subject shapes are unified under the one helper by passing
the formatted subject as a parameter:
- `&format!("<production> \`{name}\`")` for the 13 named productions
(data ×1, fn ×4, const ×3, class ×3, class method ×2)
- literal `"instance"` for the 3 nameless instance forms
- `&format!("instance method \`{name}\`")` for the 1 instance method form
The `production` tag stays separate (it's the diagnostic code,
not the human-readable text). All produced messages are
byte-identical to pre-refactor messages — the 8 duplicate-clause
unit tests from 22-tidy.5 (4 fn + 3 const + 1 data) continue
passing against verbatim assertion strings.
Tasks (commit subjects):
- 22-tidy.7: extract duplicate_clause_err helper, retire 17 inline blocks
Acceptance: `cargo test --workspace` 0 FAILED; bench gates 0/0/0;
net LOC reduction confirmed (-99 LOC). Quality reviewer noted the
call-site lines now exceed ~120 cols at some sites, but the repo
has no enforced column limit and rustfmt accepts the shape.
Observation (out-of-scope, queued): the 9 22b.4a-era duplicate-
clause sites (class ×3 + class method ×2 + instance ×3 +
instance method ×1) have no dedicated unit tests — they were
shipped without a regression pin. The 22-tidy.5 tests cover
fn/const/data only. Backfilling tests for the 22b.4a-era sites is
defensible but beyond the carried-debt scope; queue under
"parser-test backfill" if and when a 22b.4a-era diagnostic ever
needs to change.
Carried-debt status (after this iter):
- ✅ Primitive-name-set consolidation (22-tidy.4).
- ✅ Strict duplicate-clause detection in fn/const/data (22-tidy.5).
- ✅ Form-B (prose) printer arms for ClassDef / InstanceDef
(22-tidy.6).
- ✅ Strict-clause helper consolidation (this iter).
- ✅ Lib.rs gap-related sites — audit confirmed defensive.
Milestone-22 carried debt + the queued tipping-point observation
are now both closed. Next milestone targets remain orchestrator's
call.