You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cathedral sweep: audit each compiler file for per-path logic that should be a single source of truth #651
The share-place work re-established one cathedral — compute_fn_abi(sig) as the single ABI descriptor (FnAbi / PassMode), read by both the callee prologue and every call site, so caller/callee/path divergence is impossible (see docs/decisions.md D6, docs/fn_abi_descriptor_design.md). That divergence — a per-path "value vs address vs byval" decision reinvented in several places — was the exact bug that produced the transparent T*/T** mismatch.
The lesson generalizes: anywhere the compiler makes the same semantic decision in more than one place, it's a bazaar and a latent divergence bug. We should sweep the compiler for these and cathedralize them.
Task
Go through the compiler one file at a time (src/*.w, src/compiler/*.w) and, for each, identify logic that should be centralized into a single source of truth. Look for:
The same classification/decision computed per-path instead of once (like the pre-D6 ABI decision). Examples of the shape to hunt: "is this passed by value or by address", "does this place need a drop", "is this receiver a borrow or owned", "how is a ref-arg's address materialized", "which types are Copy", "how a constant is read from an operand".
Parallel if/else ladders over the same kinds that drift out of sync.
Helpers that reimplement a query that already exists elsewhere (e.g. drop-schedule lookups, receiver-mode detection, effect classification).
Places that read a derived fact by re-deriving it rather than reading the canonical descriptor.
For each finding: note the file, the duplicated decision, where the canonical source of truth is (or should be), and the risk it poses (what divergence bug it could cause). Propose the cathedral (the one function/descriptor to compute it) and the read sites that should consume it.
Method
One file per pass; produce a short report per file (findings + proposed cathedral), not a blanket refactor.
Prioritize the hot correctness paths first: MIR lowering (MirLower.w), codegen (Codegen.w, CodegenDispatch.w), sema ownership/effects (Sema.w, SemaCheck.w, SemaDecl.w).
Each cathedralization lands as its own change with the full gate (with build && :fixpoint && :test) green.
References
docs/decisions.md D6 (FnAbi single ABI source of truth), D5 (share-place).
docs/fn_abi_descriptor_design.md.
Architecture issue, not a spec gap — no docs/with-specification.md section applies.
Cathedral-sweep candidate found during #668: src/CCodegen.w has the place-projection walk duplicated four times — the text renderer (place_text's projection loop) plus three near-identical tid walkers (place_tid, place_ref_target_tid, place_tid_no_infer). The #668 fix had to patch PK_TUPLE_INDEX into all four; before that, the renderer knew projections the tid walkers didn't, which produced the classic divergence bug (tuple field rendered correctly but typed as unknown → str == emitted as raw C ==). One projection-walk source of truth (walk once, yield text+tid together, or share the kind dispatch) would make that class impossible.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): still open. The candidate the last comment names is still there: src/CCodegen.w has the three tid walkers (place_tid, place_ref_target_tid, place_tid_no_infer) beside the text renderer.
Cathedralized src/CCodegen.with in PR #3673: replaced the four duplicated place-projection walkers (place_tid, place_ref_target_tid, place_tid_no_infer, place_text) named in the earlier comments with one canonical walk_place_projections returning CcPlaceWalk (+156 / -373 lines net). Verified across all 47 test/emit_c/*.with fixtures and full seed-driven battery (emit-c-smoke green).
Activity
Sema/MIR: require bool conditions; accept the unit pattern (#654, #631)
emit-C: set inserts, canonical map key types, tuple projections (#668)
ehartford commentedon Jul 17, 2026
Cathedral-sweep candidate found during #668: src/CCodegen.w has the place-projection walk duplicated four times — the text renderer (
place_text's projection loop) plus three near-identical tid walkers (place_tid,place_ref_target_tid,place_tid_no_infer). The #668 fix had to patchPK_TUPLE_INDEXinto all four; before that, the renderer knew projections the tid walkers didn't, which produced the classic divergence bug (tuple field rendered correctly but typed as unknown → str==emitted as raw C==). One projection-walk source of truth (walk once, yield text+tid together, or share the kind dispatch) would make that class impossible.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): still open. The candidate the last comment names is still there:src/CCodegen.whas the three tid walkers (place_tid,place_ref_target_tid,place_tid_no_infer) beside the text renderer.post-release: an open-ended audit.
Wave 2b: CCodegen place-walk unification (#651), hermetic offline wit…
ehartford commentedon Nov 28, 2026
Cathedralized
src/CCodegen.within PR #3673: replaced the four duplicated place-projection walkers (place_tid,place_ref_target_tid,place_tid_no_infer,place_text) named in the earlier comments with one canonicalwalk_place_projectionsreturningCcPlaceWalk(+156 / -373lines net). Verified across all 47test/emit_c/*.withfixtures and full seed-driven battery (emit-c-smokegreen).