//! Pins the Show-aware `no-instance` diagnostic shipped in milestone 24.3. //! //! Property protected: calling `print` on a function type fires the //! `no-instance` diagnostic with a Show-aware message that //! cross-references design/contracts/0013-typeclasses.md, so the //! LLM author immediately learns which types ship with built-in Show //! and how to declare their own instance for a user type. use ailang_check::check_workspace; use ailang_surface::load_workspace; use std::path::PathBuf; fn fixture(name: &str) -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("../../examples") .join(name) } #[test] fn print_on_fn_type_fires_show_aware_no_instance() { let ws = load_workspace(&fixture("show_no_instance.ail")).expect("load"); let diags = check_workspace(&ws); assert!( !diags.is_empty(), "expected NoInstance Show diagnostic, got no diagnostics" ); let no_inst = diags .iter() .find(|d| d.code == "no-instance") .unwrap_or_else(|| { panic!("expected diagnostic with code 'no-instance', got: {diags:#?}") }); // Must mention Show. assert!( no_inst.message.contains("Show"), "expected Show-aware NoInstance diagnostic, got message: {:?}", no_inst.message ); // Must cross-reference design/contracts/0013-typeclasses.md — that's // the canonical contract naming which types ship with Show. assert!( no_inst.message.contains("design/contracts/0013-typeclasses.md"), "expected design/contracts/0013-typeclasses.md cross-reference, got message: {:?}", no_inst.message ); }