iter 22b.3.5: fix — quality-review (chained-call test, hoist class_index, drop noise comments)

This commit is contained in:
2026-05-09 20:59:43 +02:00
parent dd87b36e00
commit e8018d48b6
3 changed files with 126 additions and 7 deletions
+52
View File
@@ -390,3 +390,55 @@ fn fixpoint_dedupes_repeated_calls_at_same_type() {
}
assert_eq!(count, 1, "exactly one show#Int across the workspace");
}
/// Property: when a synthesised instance body itself calls another class
/// method (the canonical `Eq.ne x y = not (eq x y)` shape), the workspace
/// fixpoint closes over the chained call — Round 1 synthesises the outer
/// fn, Round 2 picks up the inner class-method residual on the freshly-
/// appended body and synthesises that. Without the multi-round loop, the
/// inner mono fn would be missing.
///
/// Fixture (`test_22b3_chained_calls`):
/// class B a where b_method : (a) -> Int
/// class A a where a_method : (a) -> Int default \x. b_method x
/// instance B Int { b_method = \y. y }
/// instance A Int { /* uses class default */ }
/// main : () -> Int = a_method 5
///
/// Expected post-mono workspace contents: BOTH `a_method#Int` (Round 1,
/// from the class default) AND `b_method#Int` (Round 2, from instance B's
/// body).
#[test]
fn fixpoint_handles_chained_class_method_calls() {
let entry = examples_dir().join("test_22b3_chained_calls.ail.json");
let ws = ailang_core::load_workspace(&entry).expect("load");
let diags = ailang_check::check_workspace(&ws);
assert!(diags.is_empty(), "fixture must typecheck: {:?}", diags);
let ws = ailang_check::monomorphise_workspace(&ws).expect("mono");
// Locate both synthesised fns workspace-wide.
let mut has_a_method_int = false;
let mut has_b_method_int = false;
for m in ws.modules.values() {
for d in &m.defs {
if let ailang_core::ast::Def::Fn(f) = d {
if f.name == "a_method#Int" {
has_a_method_int = true;
}
if f.name == "b_method#Int" {
has_b_method_int = true;
}
}
}
}
assert!(
has_a_method_int,
"a_method#Int must be synthesised in Round 1 from main's call site"
);
assert!(
has_b_method_int,
"b_method#Int must be synthesised in Round 2 from a_method#Int's body \
— multi-round fixpoint property"
);
}