Iter 4b: ail diff für semantischen Modul-Vergleich

ail diff <a> <b> [--json] vergleicht zwei Module strukturell per
Def-Hash. Vier Kategorien (added/removed/changed/unchanged),
alphabetisch sortiert, deterministisches JSON-Schema. Exit 1 bei
Unterschieden, Exit 0 bei Identität — skript-tauglich. Kein
Typcheck-Zwang, damit man auch kaputte Module diffen kann. Helper
def_name/def_kind in ailang-core für stabile Def-Identität.
This commit is contained in:
2026-05-07 11:11:48 +02:00
parent 93fe7237e3
commit c652b12582
4 changed files with 377 additions and 1 deletions
+16
View File
@@ -36,6 +36,22 @@ impl Def {
}
}
/// Externer Helper: Name einer Definition (für Tools wie `ail diff`,
/// die den Def-Knoten entkoppelt vom Methoden-Aufruf konsumieren).
pub fn def_name(def: &Def) -> &str {
def.name()
}
/// Externer Helper: Diskriminator-Tag einer Definition (`fn`, `const`, `type`).
/// Identisch mit dem `kind`-Feld in der JSON-Repräsentation.
pub fn def_kind(def: &Def) -> &'static str {
match def {
Def::Fn(_) => "fn",
Def::Const(_) => "const",
Def::Type(_) => "type",
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TypeDef {
pub name: String,
+3 -1
View File
@@ -8,7 +8,9 @@ pub mod canonical;
pub mod hash;
pub mod pretty;
pub use ast::{ConstDef, Def, FnDef, Import, Literal, Module, Term, Type};
pub use ast::{
def_kind, def_name, ConstDef, Def, FnDef, Import, Literal, Module, Term, Type,
};
pub use hash::def_hash;
#[derive(Debug, thiserror::Error)]