iter ct.1.6: wire validator into load_workspace; refresh kind-mismatch test
This commit is contained in:
@@ -452,6 +452,12 @@ pub fn load_workspace(entry_path: &Path) -> Result<Workspace, WorkspaceLoadError
|
|||||||
let prelude = load_prelude();
|
let prelude = load_prelude();
|
||||||
modules.insert("prelude".to_string(), prelude);
|
modules.insert("prelude".to_string(), prelude);
|
||||||
|
|
||||||
|
// ct.1: enforce the canonical-form rule on Type::Con and
|
||||||
|
// Term::Ctor.type_name. Runs before class-schema validation
|
||||||
|
// so a stale bare cross-module ref fires the canonical-form
|
||||||
|
// diagnostic instead of a downstream one.
|
||||||
|
validate_canonical_type_names(&modules)?;
|
||||||
|
|
||||||
// Iter 22b.2: class-schema validation runs before registry
|
// Iter 22b.2: class-schema validation runs before registry
|
||||||
// construction so that ill-kinded class definitions are rejected
|
// construction so that ill-kinded class definitions are rejected
|
||||||
// before any instance against them is registered.
|
// before any instance against them is registered.
|
||||||
@@ -1796,25 +1802,30 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iter 22b.2: a class whose parameter `f` appears in applied
|
/// ct.1: a class whose parameter `f` appears as a `Type::Con`
|
||||||
/// position (`Type::Con { name == "f", args.len() > 0 }`) inside
|
/// name (the malformed-but-historically-test-fixture shape used
|
||||||
/// a method signature must fire `KindMismatch`. Decision 11 axis
|
/// to trigger `KindMismatch` pre-ct.1) is now caught earlier by
|
||||||
/// 5 forbids HKTs — class params are kind `*` only, never
|
/// the canonical-type-names validator: `f` is bare,
|
||||||
/// constructors.
|
/// non-primitive, and not a TypeDef in the owning module, so
|
||||||
|
/// `BareCrossModuleTypeRef` fires before `validate_classdefs`
|
||||||
|
/// gets a chance to run. The `KindMismatch` path stays in the
|
||||||
|
/// codebase as dead-but-defensive code; a future tidy may
|
||||||
|
/// retire it.
|
||||||
#[test]
|
#[test]
|
||||||
fn class_param_in_applied_position_fires_kind_mismatch() {
|
fn class_param_in_applied_position_fires_canonical_form_rejection() {
|
||||||
let entry = std::path::PathBuf::from(
|
let entry = std::path::PathBuf::from(
|
||||||
"../../examples/test_22b2_kind_mismatch.ail.json",
|
"../../examples/test_22b2_kind_mismatch.ail.json",
|
||||||
);
|
);
|
||||||
let err = load_workspace(&entry)
|
let err = load_workspace(&entry)
|
||||||
.expect_err("must fire kind-mismatch");
|
.expect_err("must fire canonical-form rejection");
|
||||||
match err {
|
match err {
|
||||||
WorkspaceLoadError::KindMismatch { class, param, method, .. } => {
|
WorkspaceLoadError::BareCrossModuleTypeRef { module, name, .. } => {
|
||||||
assert_eq!(class, "Functor");
|
assert_eq!(module, "test_22b2_kind_mismatch");
|
||||||
assert_eq!(param, "f");
|
assert_eq!(name, "f");
|
||||||
assert_eq!(method, "fmap");
|
|
||||||
}
|
}
|
||||||
other => panic!("expected KindMismatch, got {other:?}"),
|
other => panic!(
|
||||||
|
"expected BareCrossModuleTypeRef (validator now fires first), got {other:?}",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user