From edb694fdceea883d785504b95399b415bc2dc634 Mon Sep 17 00:00:00 2001 From: Brummel Date: Mon, 11 May 2026 09:16:20 +0200 Subject: [PATCH] iter ct.2.2-doctidy: refresh stale doc-comments on UnknownCtorInPattern and mono_xmod_ctor_pattern --- crates/ail/tests/mono_xmod_ctor_pattern.rs | 15 ++++++++++----- crates/ailang-check/src/lib.rs | 7 +++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/ail/tests/mono_xmod_ctor_pattern.rs b/crates/ail/tests/mono_xmod_ctor_pattern.rs index e2c374e..9f96170 100644 --- a/crates/ail/tests/mono_xmod_ctor_pattern.rs +++ b/crates/ail/tests/mono_xmod_ctor_pattern.rs @@ -48,14 +48,19 @@ fn examples_dir() -> PathBuf { /// `head_or_zero : test_mono_ctor_listmod.List -> Int` that /// matches on `Cons h _ | Nil`. /// -/// Pre-fix repro: `monomorphise_workspace` returns +/// Pre-ct.2 repro: `monomorphise_workspace` returned /// `Err(CheckError::PatternTypeMismatch { ctor: "Cons", ty: /// "test_mono_ctor_listmod.List" })`. The same workspace -/// typechecks cleanly because `check_in_workspace` clears the flat -/// `ctor_index` before running `Pattern::Ctor` resolution. +/// typechecked cleanly because the typecheck pass overlaid a +/// per-module `ctor_index` whose imports-fallback produced the +/// qualified `resolved_type_name`, while the mono pass kept the +/// workspace-flat index whose local hit produced the bare one. /// -/// Post-fix expectation: `monomorphise_workspace` returns `Ok` and the -/// `head_or_zero` fn body's match arm types correctly. +/// Post-ct.2 expectation: `monomorphise_workspace` returns `Ok` +/// because the Pattern::Ctor lookup no longer consults +/// `ctor_index` at all — it walks directly from the scrutinee's +/// canonical `Type::Con.name` to its TypeDef in +/// `env.module_types` and validates the ctor by name there. #[test] fn mono_pass_handles_xmod_ctor_pattern() { let entry = examples_dir().join("test_mono_ctor_main.ail.json"); diff --git a/crates/ailang-check/src/lib.rs b/crates/ailang-check/src/lib.rs index b724984..4095b2d 100644 --- a/crates/ailang-check/src/lib.rs +++ b/crates/ailang-check/src/lib.rs @@ -345,8 +345,11 @@ pub enum CheckError { #[error("type `{ty}` has no constructor `{ctor}`")] UnknownCtor { ty: String, ctor: String }, - /// A pattern referenced a ctor not in [`Env::ctor_index`]. Code: - /// `unknown-ctor-in-pattern`. + /// A pattern referenced a ctor that does not exist in the + /// scrutinee's resolved [`TypeDef`]. The Pattern::Ctor lookup + /// is type-driven (post-ct.2): it walks `td.ctors` for the + /// `expected` Type::Con's TypeDef and reports this code when + /// no ctor of that name is present. Code: `unknown-ctor-in-pattern`. #[error("unknown constructor `{0}` in pattern")] UnknownCtorInPattern(String),