iter 22b.2.10: no-instance per-fn diagnostic
This commit is contained in:
@@ -212,3 +212,26 @@ fn fn_with_superclass_constraint_calling_subclass_method_fires_missing_constrain
|
||||
diagnostics.iter().map(|d| &d.code).collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
|
||||
/// Property protected: a (monomorphic) fn that calls a class method at a
|
||||
/// fully-concrete type for which no `instance C T` exists in the workspace
|
||||
/// MUST receive a `no-instance` diagnostic. This is the dual of
|
||||
/// `missing-constraint`: when the residual class constraint resolves to a
|
||||
/// concrete type, the fn cannot push the obligation to a caller via a
|
||||
/// `Forall.constraints` annotation — it can only be discharged by an
|
||||
/// existing instance. Without this check, monomorphisation in 22b.3 would
|
||||
/// have nothing to specialise to. Fixture: `main` calls `show 42` (so the
|
||||
/// residual is `(Show, Int)`) without any `instance Show Int` declared in
|
||||
/// the workspace.
|
||||
#[test]
|
||||
fn fn_calling_class_method_at_type_without_instance_fires_no_instance() {
|
||||
let entry = examples_dir().join("test_22b2_no_instance.ail.json");
|
||||
let ws = ailang_core::workspace::load_workspace(&entry)
|
||||
.expect("workspace loads");
|
||||
let diagnostics = ailang_check::check_workspace(&ws);
|
||||
assert!(
|
||||
diagnostics.iter().any(|d| d.code == "no-instance"),
|
||||
"expected no-instance; got: {:?}",
|
||||
diagnostics.iter().map(|d| &d.code).collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user