floats iter 1.2: register Float as a primitive type name

This commit is contained in:
2026-05-10 14:42:23 +02:00
parent 93fe2da33c
commit aa5b88e8d4
+10 -2
View File
@@ -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\""
);
}
}