92e830e6c2
Five polymorphic prelude free fns (ne/lt/le/gt/ge) plus three E2E fixtures: positive composition over Int/Bool/Str, user-ADT with user-written Eq/Ord on IntBox, and Float-NoInstance with a Float-aware diagnostic addendum cross-referencing DESIGN.md §"Float semantics". Two checker-side fixes were needed alongside the prelude additions, both symmetric to the iter 23.4-prep visibility fix: - linearity::check_module_with_visible — workspace-aware callee-mode resolution so a Borrow-mode user fn forwarding into a prelude poly fn (e.g. `at_most x y = not (gt x y)`) doesn't false-fire consume-while-borrowed. - mono::collect_mono_targets — distinguish rigid forall vars from unbound metavars; rigid-bearing free-fn targets skip (they get re-collected with concrete subst when the enclosing fn itself monomorphises). Without this, a polymorphic body calling another polymorphic free fn produced a spurious __Unit specialisation whose body referenced compare at Unit. Roadmap split: shipped Eq/Ord half checked, Show + print-rewire half remains pending behind the heap-Str ABI prerequisite. DESIGN.md §"Prelude classes" amended. One pre-existing fixture (test_22b1_missing_method) renamed its class method ne → tne to avoid collision with the new prelude `ne`. Bench: check.py + cross_lang.py exit 0; compile_check.py exits 1 with one sub-ms check_ms.local_rec_capture at +26% (tolerance 25%) — prelude-growth-related noise-band fluctuation, ratifiable per spec §248-249 and journal Concerns.
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
//! Pins the Float-aware `NoInstance` diagnostic added in milestone 23.
|
|
//!
|
|
//! Property protected: a polymorphic Eq/Ord helper invoked at Float
|
|
//! fires `no-instance` (since Float has neither Eq nor Ord instance
|
|
//! per DESIGN.md §"Float semantics") AND the diagnostic message
|
|
//! cross-references the canonical Float-semantics section so the
|
|
//! LLM author immediately learns the partial-Float story rather
|
|
//! than seeing a bare "no instance" message.
|
|
|
|
use ailang_check::check_workspace;
|
|
use ailang_core::workspace::load_workspace;
|
|
use std::path::PathBuf;
|
|
|
|
fn fixture(name: &str) -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../examples")
|
|
.join(name)
|
|
}
|
|
|
|
#[test]
|
|
fn eq_at_float_fires_float_aware_noinstance() {
|
|
let ws = load_workspace(&fixture("eq_float_noinstance.ail.json")).expect("load");
|
|
let diags = check_workspace(&ws);
|
|
|
|
assert!(!diags.is_empty(), "expected NoInstance diagnostic, got none");
|
|
|
|
let no_inst = diags
|
|
.iter()
|
|
.find(|d| d.code == "no-instance")
|
|
.unwrap_or_else(|| panic!("expected diagnostic with code 'no-instance', got: {diags:#?}"));
|
|
|
|
assert!(
|
|
no_inst.message.contains("Float"),
|
|
"expected Float-aware NoInstance diagnostic, got message: {:?}",
|
|
no_inst.message
|
|
);
|
|
|
|
// Cross-ref to DESIGN.md §Float semantics — the LLM author should be
|
|
// pointed at the canonical explanation of partial Float orderability.
|
|
assert!(
|
|
no_inst.message.contains("Float semantics") || no_inst.message.contains("DESIGN"),
|
|
"expected NoInstance message to cross-reference DESIGN.md §Float semantics, got: {:?}",
|
|
no_inst.message
|
|
);
|
|
}
|