iter mq.1: class-ref canonical-form extension + workspace-internal class-name qualification

Three schema fields move bare → canonical (bare for same-module,
<module>.<Class> for cross-module): InstanceDef.class,
Constraint.class, SuperclassRef.class. Symmetric to ct.1's
Type::Con.name rule. ClassDef.name stays bare.

validate_canonical_type_names gains three field-walks via new
check_class_ref helper + two sibling diagnostics
BareCrossModuleClassRef / BadCrossModuleClassRef.
check_class_name_fields narrowed to ClassDef.name-only.

Workspace-internal class-name keys all qualified:
class_def_module, class_by_name, registry entries.0,
ClassMethodEntry.class_name, class_superclasses, mono's
class_index, Origin::Class.class_name. New qualify_class_ref
helper at workspace.rs scope plus sibling
qualify_class_ref_in_check in ailang-check.

Two new positive on-disk fixtures (mq1_xmod_constraint_class{,_dep})
exercise the qualified Constraint.class shape.

Recon claim that all existing fixtures' class-refs are intra-module
was empirically wrong — 10 fixtures required minimal canonical-form
migration. Duplicate-instance test architecturally restructured:
post-mq.1 orphan-freedom makes two-modules-on-same-(class,type)
structurally impossible; new test_22b1_dup_same_module fixture
lands both instances in the class's module.

Plan defects fixed inline: Origin::Class.class_name single
construction site (plan recon off-by-one); build_class_index in
mono.rs needed qualifying; build_module_globals needed Def::Instance
carve-out; check_fn declared-constraint matching needed inline
canonical-form lifting; NoInstance Float-aware message arm needed
prelude.Eq/prelude.Ord match; coherence type-leg needed qualified-
head split-and-lookup. Tasks 3-6 ran as one coherent fix.

7/7 tasks, 520 tests green. bench/compile_check.py + cross_lang.py
exit 0; bench/check.py exit 1 (4 improvements-beyond-tolerance,
audit-ratifiable, not a regression).

MethodNameCollision + dispatch path unchanged; iters mq.2 + mq.3
land them.
This commit is contained in:
2026-05-13 01:11:56 +02:00
parent 1a5f8289b7
commit 0eb33235eb
28 changed files with 1159 additions and 234 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
"type": {
"k": "forall",
"vars": ["a"],
"constraints": [{ "class": "Ord", "type": { "k": "var", "name": "a" } }],
"constraints": [{ "class": "prelude.Ord", "type": { "k": "var", "name": "a" } }],
"body": {
"k": "fn",
"params": [{ "k": "var", "name": "a" }, { "k": "var", "name": "a" }],
+1 -1
View File
@@ -10,7 +10,7 @@
},
{
"kind": "instance",
"class": "MyC",
"class": "ctt2_collision_cls.MyC",
"type": { "k": "con", "name": "Foo" },
"methods": [
{
+1 -1
View File
@@ -13,7 +13,7 @@
},
{
"kind": "instance",
"class": "MyC",
"class": "ctt2_collision_cls.MyC",
"type": { "k": "con", "name": "Foo" },
"methods": [
{
+1 -1
View File
@@ -10,7 +10,7 @@
"type": {
"k": "forall",
"vars": ["a"],
"constraints": [{ "class": "Ord", "type": { "k": "var", "name": "a" } }],
"constraints": [{ "class": "prelude.Ord", "type": { "k": "var", "name": "a" } }],
"body": {
"k": "fn",
"params": [
+2 -2
View File
@@ -14,7 +14,7 @@
},
{
"kind": "instance",
"class": "Eq",
"class": "prelude.Eq",
"type": { "k": "con", "name": "IntBox" },
"doc": "Eq IntBox by structural unwrap of the inner Int.",
"methods": [
@@ -56,7 +56,7 @@
},
{
"kind": "instance",
"class": "Ord",
"class": "prelude.Ord",
"type": { "k": "con", "name": "IntBox" },
"doc": "Ord IntBox by delegating to Int's compare on the inner field.",
"methods": [
@@ -0,0 +1,29 @@
{
"schema": "ailang/v0",
"name": "mq1_xmod_constraint_class",
"imports": [{ "module": "mq1_xmod_constraint_class_dep" }],
"defs": [
{
"kind": "fn",
"name": "useShow",
"doc": "Positive mq.1 fixture: a polymorphic fn that takes a single value and a Show constraint, ignores the value, and returns Unit. Exercises the qualified `Constraint.class` shape end-to-end (loader + validator + check_workspace).",
"type": {
"k": "forall",
"vars": ["a"],
"constraints": [
{ "class": "mq1_xmod_constraint_class_dep.Show",
"type": { "k": "var", "name": "a" } }
],
"body": {
"k": "fn",
"params": [{ "k": "var", "name": "a" }],
"param_modes": ["borrow"],
"ret": { "k": "con", "name": "Unit" },
"effects": []
}
},
"params": ["_x"],
"body": { "t": "lit", "lit": { "kind": "unit" } }
}
]
}
@@ -0,0 +1,23 @@
{
"schema": "ailang/v0",
"name": "mq1_xmod_constraint_class_dep",
"imports": [],
"defs": [
{
"kind": "class",
"name": "Show",
"param": "a",
"methods": [
{
"name": "show",
"type": {
"k": "fn",
"params": [{ "k": "var", "name": "a" }],
"ret": { "k": "con", "name": "Str" },
"effects": []
}
}
]
}
]
}
+5 -26
View File
@@ -4,36 +4,15 @@
"imports": [
{
"module": "test_22b1_dup_b"
},
{
"module": "test_22b1_dup_classmod"
}
],
"defs": [
{
"kind": "class",
"name": "Show",
"param": "a",
"methods": [
{
"name": "show",
"type": {
"k": "fn",
"params": [
{
"k": "var",
"name": "a"
}
],
"ret": {
"k": "con",
"name": "Str"
},
"effects": []
}
}
]
},
{
"kind": "instance",
"class": "Show",
"class": "test_22b1_dup_classmod.Show",
"type": {
"k": "con",
"name": "test_22b1_dup_b.MyInt"
@@ -52,4 +31,4 @@
]
}
]
}
}
+4 -2
View File
@@ -1,7 +1,9 @@
{
"schema": "ailang/v0",
"name": "test_22b1_dup_b",
"imports": [],
"imports": [
{ "module": "test_22b1_dup_classmod" }
],
"defs": [
{
"kind": "type",
@@ -15,7 +17,7 @@
},
{
"kind": "instance",
"class": "Show",
"class": "test_22b1_dup_classmod.Show",
"type": { "k": "con", "name": "MyInt" },
"methods": [
{
+23
View File
@@ -0,0 +1,23 @@
{
"schema": "ailang/v0",
"name": "test_22b1_dup_classmod",
"imports": [],
"defs": [
{
"kind": "class",
"name": "Show",
"param": "a",
"methods": [
{
"name": "show",
"type": {
"k": "fn",
"params": [{ "k": "var", "name": "a" }],
"ret": { "k": "con", "name": "Str" },
"effects": []
}
}
]
}
]
}
+2 -1
View File
@@ -3,7 +3,8 @@
"name": "test_22b1_dup_entry",
"imports": [
{ "module": "test_22b1_dup_a" },
{ "module": "test_22b1_dup_b" }
{ "module": "test_22b1_dup_b" },
{ "module": "test_22b1_dup_classmod" }
],
"defs": []
}
@@ -0,0 +1,45 @@
{
"schema": "ailang/v0",
"name": "test_22b1_dup_same_module",
"imports": [],
"defs": [
{
"kind": "class",
"name": "Show",
"param": "a",
"methods": [
{
"name": "show",
"type": {
"k": "fn",
"params": [{ "k": "var", "name": "a" }],
"ret": { "k": "con", "name": "Str" },
"effects": []
}
}
]
},
{
"kind": "instance",
"class": "Show",
"type": { "k": "con", "name": "Int" },
"methods": [
{
"name": "show",
"body": { "t": "lit", "lit": { "kind": "str", "value": "first" } }
}
]
},
{
"kind": "instance",
"class": "Show",
"type": { "k": "con", "name": "Int" },
"methods": [
{
"name": "show",
"body": { "t": "lit", "lit": { "kind": "str", "value": "second" } }
}
]
}
]
}
+1 -1
View File
@@ -7,7 +7,7 @@
"defs": [
{
"kind": "instance",
"class": "Show",
"class": "test_22b1_orphan_third_classmod.Show",
"type": { "k": "con", "name": "Int" },
"methods": [
{
@@ -3,6 +3,12 @@
"name": "test_22b2_unbound_constraint_var",
"imports": [],
"defs": [
{
"kind": "class",
"name": "Bar",
"param": "x",
"methods": []
},
{
"kind": "class",
"name": "Foo",