e406d07d81
Tasks 4-7 on the Boss-Repaired plan, completing the M1 iteration: - Task 4: check-side export-signature gate — CheckError variants ExportNonScalarSignature / ExportHasEffects (codes export-non-scalar-signature / export-has-effects), code() arms, check_fn gate (params->ret->effects, first-violation-wins, unconditional on f.export.is_some()). The clause-3 discriminator in code: effectful/non-scalar exports fail to typecheck. 6/6. - Task 5: codegen Target::StaticLib — Target enum, threaded param, @main/MissingEntryMain gated behind Target::Executable, one external @<sym> forwarder per export to @ail_<module>_<fn> (fn_scalar_sig/llvm_scalar). In-source missing_entry_main_is_error byte-unchanged. Lowering pin 2/2. - Task 6: CLI ail build --emit=staticlib — clap field, Cmd::Build branch, build_staticlib (verbatim build_to prefix + has_export guard + two-archive clang -c/ar rcs tail) + run_cmd. CLI pin 2/2. - Task 7: C-host E2E coherent-stop proof (cc links libembed_backtest_step.a + libailang_rt.a, backtest_step(0,3)=9 / (9,4)=25, s==25, exit 0) + DESIGN.md §"Embedding ABI (M1)" (scalar C ABI, provisional until M3). E2E pin 1/1. Independent Boss verification: E2E 1/1, gate 6/6, full workspace 0 failures, roundtrip_cli + design_schema_drift + spec_drift green, Invariant 1 holds (no new dep in core/codegen/runtime). 3 behaviour- neutral plan pseudo-vs-reality concerns in the journal. Default-exe codegen/runtime path byte-unchanged (check.py firing = tracked-P2 known-noise, audit-adjudicated). INDEX line added. Completes the M1 iteration (impl). Milestone-close audit + fieldtest (surface-touching) are the next pipeline steps.
64 lines
2.0 KiB
Rust
64 lines
2.0 KiB
Rust
//! Embedding-ABI M1 export-signature gate (spec §3, clause-3
|
|
//! discriminator): an `(export …)` fn whose params/ret are not all
|
|
//! `Int`/`Float`, or whose effect set is non-empty, MUST fail
|
|
//! `ail check` with the new diagnostic. A scalar+pure export passes.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
fn examples_dir() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.parent().unwrap().parent().unwrap()
|
|
.join("examples")
|
|
}
|
|
|
|
fn check_codes(file: &str) -> Vec<String> {
|
|
let path = examples_dir().join(file);
|
|
let ws = ailang_surface::load_workspace(&path)
|
|
.unwrap_or_else(|e| panic!("load {file}: {e}"));
|
|
ailang_check::check_workspace(&ws)
|
|
.into_iter()
|
|
.map(|d| d.code)
|
|
.collect()
|
|
}
|
|
|
|
#[test]
|
|
fn str_param_export_rejected() {
|
|
assert!(check_codes("embed_export_str_param_rejected.ail")
|
|
.iter().any(|c| c == "export-non-scalar-signature"));
|
|
}
|
|
|
|
#[test]
|
|
fn adt_ret_export_rejected() {
|
|
assert!(check_codes("embed_export_adt_ret_rejected.ail")
|
|
.iter().any(|c| c == "export-non-scalar-signature"));
|
|
}
|
|
|
|
#[test]
|
|
fn io_export_rejected() {
|
|
assert!(check_codes("embed_export_io_rejected.ail")
|
|
.iter().any(|c| c == "export-has-effects"));
|
|
}
|
|
|
|
#[test]
|
|
fn combined_effectful_export_rejected_on_signature_first() {
|
|
let codes = check_codes("embed_export_effectful_rejected.ail");
|
|
assert!(codes.iter().any(|c| c == "export-non-scalar-signature"),
|
|
"combined fixture must fail signature-first; got {codes:?}");
|
|
}
|
|
|
|
#[test]
|
|
fn scalar_pure_export_passes() {
|
|
let codes = check_codes("embed_export_float_ok.ail");
|
|
assert!(!codes.iter().any(|c|
|
|
c == "export-non-scalar-signature" || c == "export-has-effects"),
|
|
"scalar+pure export must pass the gate; got {codes:?}");
|
|
}
|
|
|
|
#[test]
|
|
fn headline_int_export_passes() {
|
|
let codes = check_codes("embed_backtest_step.ail");
|
|
assert!(!codes.iter().any(|c|
|
|
c == "export-non-scalar-signature" || c == "export-has-effects"),
|
|
"headline export must pass the gate; got {codes:?}");
|
|
}
|