iter 22-tidy.4: route 4 matches! sites through is_primitive_name

This commit is contained in:
2026-05-10 04:15:47 +02:00
parent 9523a1cd63
commit 5fd95e4e9f
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -1276,7 +1276,7 @@ fn check_type_def(td: &TypeDef, env: &Env) -> Result<()> {
fn check_type_well_formed(t: &Type, env: &Env) -> Result<()> {
match t {
Type::Con { name, args } => {
let is_primitive = matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str");
let is_primitive = ailang_core::primitives::is_primitive_name(name);
if is_primitive {
if !args.is_empty() {
return Err(CheckError::UnknownType(format!(
@@ -2258,7 +2258,7 @@ fn qualify_local_types(t: &Type, owner_module: &str, local_types: &IndexMap<Stri
Type::Con { name, args } => {
let qualified_name = if name.contains('.') {
name.clone()
} else if matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str") {
} else if ailang_core::primitives::is_primitive_name(name) {
name.clone()
} else if local_types.contains_key(name) {
format!("{owner_module}.{name}")
+1 -1
View File
@@ -140,7 +140,7 @@ use std::collections::HashMap;
/// == 0`.
fn is_heap_type(t: &Type) -> bool {
match t {
Type::Con { name, .. } => !matches!(name.as_str(), "Int" | "Bool" | "Str" | "Unit"),
Type::Con { name, .. } => !ailang_core::primitives::is_primitive_name(name),
// Type::Var (a polymorphic param) is conservatively heap —
// it could instantiate to a heap type at the call site.
Type::Var { .. } => true,
+1 -1
View File
@@ -166,7 +166,7 @@ pub(crate) fn qualify_local_types_codegen(
Type::Con { name, args } => {
let qualified = if name.contains('.') {
name.clone()
} else if matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str") {
} else if ailang_core::primitives::is_primitive_name(name) {
name.clone()
} else if owner_local_types.contains(name) {
format!("{owner_module}.{name}")