ac4d545570
Follow-up to bcd4181: the remaining ~530 inline `//` and `///`
comments still carrying opaque shorthand are now reformulated to
their content phrases. The only surviving `iter-<code>` reference
in source is the literal filename
`docs/journals/2026-05-13-iter-mq.3.md` (a real journal file).
Sweep covered:
- `// Iter X.Y: <text>` prefixes (Iter 13a / 14a / 14e / 15g-aux /
16b.x / 16d / 16e / 18b / 18c.x / 18d.x / 18e / 18g.x / 19a /
19a.1 / 19b / 20a / 20f / 22-floats.x / 22b.x / 22c / 23.x /
24.1 / cli-diag-human / hs.x / str-concat / etc.) — fully
removed; the descriptive text that followed each prefix stays.
- `// (Decision N)` and `per Decision N` and `Decision N axis 3` —
replaced with the content phrase plus the relevant contract
file (`design/contracts/tail-calls.md` for Decision 8,
`design/contracts/memory-model.md` for Decision 10,
`design/contracts/typeclasses.md` and `design/models/typeclasses.md`
for Decision 11, `design/contracts/authoring-surface.md` for
Decision 6, "the transitional dual-allocator" for Decision 9,
"Effect prose" for Decision 3).
- `// mq.X / mq.X (Task N) / mq.X journal / mq.X invariant` ->
"the canonical-class-form rule / Class-class repurpose /
method-dispatch-refactor journal / canonical-class-form
invariant".
- `// ct.X / ct.X (canonical-type-names) / ct.1.5a + ctt.2 /
ct.2 Task N` -> "the canonical-form rule for type references /
the canonical-form normalisation step / canonical-type-lookup
refactor".
- `// eob.X` -> "heap-Str-ABI" / "the Str carve-out".
- `// rpe.X` -> "the per-type-print-op retirement".
- `// post-mq.X / Pre-ct.X / pre-mq.X` -> "post-canonical-class-form" /
"Pre-canonical-type-form" etc.
- `/// Iter X regression: / /// Iter X.Y: / /// Iter A arm-close /
/// Iter ct.4 (...): / /// Iter rpe.1 ...` -> descriptive
phrases.
The journal filename in `crates/ailang-core/src/workspace.rs:573`
stays verbatim because it points at an actual file under
`docs/journals/`.
Tests: full `cargo test --workspace` green (80/80 test-result blocks
clean, no FAILED line). design_index_pin 5/5 + docs_honesty_pin 5/5
gating tests pass.
72 lines
2.8 KiB
Rust
72 lines
2.8 KiB
Rust
//! Regression for the `Registry.type_def_module` re-key (ctt.2).
|
|
//!
|
|
//! Two modules each declare `type Foo` with distinct ctors and
|
|
//! provide an `instance MyC Foo`. Pre-ctt.2, both bare `Foo`s
|
|
//! collide on the bare-name `BTreeMap<String, String>` key —
|
|
//! `normalize_type_for_registry` qualifies both to whichever
|
|
//! module won the insert race, and the loser's instance trips
|
|
//! a false `DuplicateInstance`. Post-ctt.2, the tuple-keyed map
|
|
//! distinguishes the two `Foo`s by owning module; both instances
|
|
//! register cleanly under distinct canonical keys.
|
|
//!
|
|
//! This test goes red today (DuplicateInstance) and green after
|
|
//! the re-key.
|
|
|
|
use ailang_core::canonical;
|
|
use ailang_core::ast::Type;
|
|
use ailang_surface::load_workspace;
|
|
use std::path::Path;
|
|
|
|
fn examples_dir() -> std::path::PathBuf {
|
|
let manifest = env!("CARGO_MANIFEST_DIR");
|
|
Path::new(manifest)
|
|
.parent().expect("CARGO_MANIFEST_DIR has a parent (crates/)")
|
|
.parent().expect("crates has a parent (workspace root)")
|
|
.join("examples")
|
|
}
|
|
|
|
#[test]
|
|
fn two_modules_with_same_bare_foo_both_register() {
|
|
let entry = examples_dir().join("ctt2_collision_main.ail");
|
|
let ws = load_workspace(&entry)
|
|
.expect("expected workspace load to succeed; both `type Foo` declarations live in distinct modules and must register under distinct canonical keys");
|
|
|
|
// Compute the canonical type hashes for the two expected entries.
|
|
let main_foo_hash = canonical::type_hash(&Type::Con {
|
|
name: "ctt2_collision_main.Foo".into(),
|
|
args: vec![],
|
|
});
|
|
let lib_foo_hash = canonical::type_hash(&Type::Con {
|
|
name: "ctt2_collision_lib.Foo".into(),
|
|
args: vec![],
|
|
});
|
|
|
|
// registry-entries key is keyed by the qualified class name.
|
|
let main_key = ("ctt2_collision_cls.MyC".to_string(), main_foo_hash);
|
|
let lib_key = ("ctt2_collision_cls.MyC".to_string(), lib_foo_hash);
|
|
|
|
assert!(
|
|
ws.registry.entries.contains_key(&main_key),
|
|
"registry missing entry for (MyC, ctt2_collision_main.Foo); entries: {:?}",
|
|
ws.registry.entries.keys().collect::<Vec<_>>()
|
|
);
|
|
assert!(
|
|
ws.registry.entries.contains_key(&lib_key),
|
|
"registry missing entry for (MyC, ctt2_collision_lib.Foo); entries: {:?}",
|
|
ws.registry.entries.keys().collect::<Vec<_>>()
|
|
);
|
|
|
|
// Defining-module sanity: each entry's defining_module matches
|
|
// the module that wrote the instance.
|
|
let main_entry = &ws.registry.entries[&main_key];
|
|
assert_eq!(
|
|
main_entry.defining_module, "ctt2_collision_main",
|
|
"main-side entry's defining_module mismatched"
|
|
);
|
|
let lib_entry = &ws.registry.entries[&lib_key];
|
|
assert_eq!(
|
|
lib_entry.defining_module, "ctt2_collision_lib",
|
|
"lib-side entry's defining_module mismatched"
|
|
);
|
|
}
|