From 22de0314cf6e4ac91c298508b5502f008330ca4c Mon Sep 17 00:00:00 2001 From: Brummel Date: Mon, 11 May 2026 09:25:13 +0200 Subject: [PATCH] journal: ct.2 typechecker cleanup --- docs/JOURNAL.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/docs/JOURNAL.md b/docs/JOURNAL.md index 6e92bc3..1ed88d3 100644 --- a/docs/JOURNAL.md +++ b/docs/JOURNAL.md @@ -14222,3 +14222,88 @@ Workspace at iter-ct.1 close: full `cargo test --workspace` green the three regression scripts not re-run for this iter (no codegen- shape change to existing fixtures beyond the surgical migration; they run at canonical-type-names milestone close after ct.4). + +## 2026-05-11 — Iteration ct.2: typechecker cleanup + +Three tasks landed in the canonical-type-names milestone's +typechecker-cleanup iteration, plus targeted follow-ups driven by +the quality-review pass. + +- **ct.2.1** (`78ccbce`): wired `qualify_local_types` into the + `env.class_methods` channel of `Term::Var` resolution, closing + the last cross-module fn-lookup boundary that did not run the + qualifier. The motivating shape: prelude declares + `class Ord a` with `compare : a -> a -> Ordering`; the method's + `Ordering` is bare-local to prelude; without the qualifier on + the class-method channel, a consumer module sees bare + `Ordering` and its pattern match against the post-ct.1 + canonical `prelude.Ordering` scrutinee no longer resolves. + Also fixed a latent gap in `qualify_local_types`'s + `Type::Forall` arm: it now recurses into `constraints[].type_`, + symmetric to the ct.1.5a-followup fix on + `normalize_type_for_registry`. Two new tests pin both + invariants. +- **ct.2.2** (`b3c3b60` + followups `0ca5b3d`, `0044467`, + `edb694f`): deleted the `Pattern::Ctor` imports-fallback (iter + 15a); replaced with type-driven lookup keyed on + `expected: Type::Con`'s canonical name. The lookup no longer + consults `env.ctor_index`; the per-module overlay now serves + only duplicate-detection at workspace build. The + `cross_module_pat_ctor_ambiguous_errors` test deleted + (ambiguity unreachable post-refactor; lookup is anchored to a + single TypeDef). The `CheckError::AmbiguousCtor` variant + + its `ambiguous-ctor` diagnostic code deleted as dead code + (quality-review pushed back on leaving it as + dead-but-defensive — the project rule is "no backwards-compat + shims for removed features"). The now-unused `Bag` test + fixture in `cross_module_ws` removed in `0044467`. Doc + comments on `UnknownCtorInPattern` and + `mono_xmod_ctor_pattern.rs` refreshed in `edb694f` to describe + the post-ct.2 mechanism. The `mono_xmod_ctor_pattern.rs` + regression test still passes — its scrutinee carries the + qualified type and the new lookup finds the TypeDef directly. +- **ct.2.3** (`97bb5e7`): deleted the `Term::Ctor` synth + imports-fallback (iter 23.1.3). Bare cross-module `type_name` + now fails closed with `UnknownType`; the post-ct.1 workspace + validator catches the shape at load time for canonical inputs. + The `CheckError::AmbiguousType` variant deleted (symmetric to + the `AmbiguousCtor` cleanup; same dead-code reasoning). Two + tests deleted (`cross_module_term_ctor_ambiguous_type_errors` + and `user_module_can_pattern_match_on_prelude_ordering_bare` + — both pinned behaviour that ct.2 removes); two tests added + (`ct2_term_ctor_bare_cross_module_fails_closed` and + `ct2_term_ctor_qualified_cross_module_resolves`). + +Remaining obsolete mechanisms (ct.3 scope): the codegen +`lookup_ctor_by_type` imports-fallback (iter 23.1.4) and the +mono `apply_per_module_ctor_index_overlay` (iter 23.2 fix +`84dcc46`). Surviving stale doc-comments at +`crates/ailang-codegen/src/lib.rs:1748` and +`crates/ail/src/main.rs:239` reference the now-removed +`AmbiguousType` / `AmbiguousCtor` paths; ct.3 (codegen) and +ct.4 (the migrate-canonical-types subcommand may itself retire +as one-shot tooling) will tidy those when the surrounding code +changes. + +Lesson from ct.2.2 quality review: the orchestrator's plan +explicitly said "leave `CheckError::AmbiguousCtor` as +dead-but-defensive, defer to a later tidy". The quality +reviewer correctly pushed back, citing CLAUDE.md's +"Avoid backwards-compatibility hacks like renaming unused +\_vars, re-exporting types, adding `// removed` comments for +removed code, etc. If you are certain that something is unused, +you can delete it completely." Lesson logged for future plan +writing: when an enum variant becomes unused as a result of +the iter's own changes, the delete belongs in the same iter, +not a later tidy. The roadmap was updated implicitly — both +variants are now gone, no roadmap entry needed. + +Workspace at iter-ct.2 close: full `cargo build --workspace` and +`cargo test --workspace` green (451 tests, 0 failed). Bench +scripts not re-run (no codegen-shape change, no fixture +migration this iter). E2E coverage skipped per implement-skill +carve-out (ct.2 ships internal refactor only; per-task pin +tests + the existing workspace test surface cover the +invariants; the canonical E2E demonstration of the +iter-23.3-Task-4 bug closure happens in ct.4 with the recreated +`compare_primitives_smoke.ail.json` fixture).