From aa5b88e8d45cbcf9b5c283ede18d717dd7ae13d5 Mon Sep 17 00:00:00 2001 From: Brummel Date: Sun, 10 May 2026 14:42:23 +0200 Subject: [PATCH] floats iter 1.2: register Float as a primitive type name --- crates/ailang-core/src/primitives.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ailang-core/src/primitives.rs b/crates/ailang-core/src/primitives.rs index 5a10434..d0cf912 100644 --- a/crates/ailang-core/src/primitives.rs +++ b/crates/ailang-core/src/primitives.rs @@ -14,7 +14,7 @@ /// typecheck-time well-formedness gating, the heap-type filter, /// the local-type qualifier, and the codegen substitution path. pub fn is_primitive_name(name: &str) -> bool { - matches!(name, "Int" | "Bool" | "Str" | "Unit") + matches!(name, "Int" | "Bool" | "Str" | "Unit" | "Float") } /// Returns the static-lifetime surface name iff `name` is a @@ -27,6 +27,7 @@ pub fn primitive_surface_name(name: &str) -> Option<&'static str> { "Bool" => Some("Bool"), "Str" => Some("Str"), "Unit" => Some("Unit"), + "Float" => Some("Float"), _ => None, } } @@ -41,12 +42,19 @@ mod tests { /// inside both functions plus a sample non-primitive. #[test] fn predicate_and_surface_name_agree() { - for name in ["Int", "Bool", "Str", "Unit", "List", "Foo", "", "int"] { + for name in ["Int", "Bool", "Str", "Unit", "Float", "List", "Foo", "", "int"] { assert_eq!( is_primitive_name(name), primitive_surface_name(name).is_some(), "lockstep violation for {name:?}" ); } + // Float is a primitive (Floats milestone, iter 1). + assert!(is_primitive_name("Float"), "Float must be a primitive"); + assert_eq!( + primitive_surface_name("Float"), + Some("Float"), + "Float surface name must be \"Float\"" + ); } }