iter 22-tidy.4: mono::primitive_surface_name delegates to ailang-core

This commit is contained in:
2026-05-10 04:18:46 +02:00
parent 5fd95e4e9f
commit 557bf57cdb
+9 -12
View File
@@ -308,20 +308,17 @@ pub fn mono_symbol(method: &str, ty: &Type) -> String {
format!("{method}__{}", &full_hash[..8])
}
/// Iter 22b.3: returns the surface name iff `ty` is a zero-arity
/// primitive `Type::Con`. Used by [`mono_symbol`] to gate the
/// human-readable form. The match is intentionally narrow:
/// `Int<args>` (which is malformed but parser-accepting) is
/// treated as compound, so it falls to the hash form.
/// Returns the surface name iff `ty` is a zero-arity primitive
/// `Type::Con`. Used by [`mono_symbol`] to gate the human-readable
/// form. The match is intentionally narrow: `Int<args>` (malformed
/// but parser-accepting) is treated as compound, so it falls to
/// the hash form. The primitive-set itself lives in
/// [`ailang_core::primitives::primitive_surface_name`].
fn primitive_surface_name(ty: &Type) -> Option<&'static str> {
match ty {
Type::Con { name, args } if args.is_empty() => match name.as_str() {
"Int" => Some("Int"),
"Bool" => Some("Bool"),
"Str" => Some("Str"),
"Unit" => Some("Unit"),
_ => None,
},
Type::Con { name, args } if args.is_empty() => {
ailang_core::primitives::primitive_surface_name(name)
}
_ => None,
}
}