diff --git a/crates/ailang-check/src/lib.rs b/crates/ailang-check/src/lib.rs index 57e81d9..08e2840 100644 --- a/crates/ailang-check/src/lib.rs +++ b/crates/ailang-check/src/lib.rs @@ -475,9 +475,8 @@ fn check_type_def(td: &TypeDef, env: &Env) -> Result<()> { fn check_type_well_formed(t: &Type, env: &Env) -> Result<()> { match t { Type::Con { name } => { - if matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str") { - Ok(()) - } else if env.types.contains_key(name) { + let is_primitive = matches!(name.as_str(), "Int" | "Bool" | "Unit" | "Str"); + if is_primitive || env.types.contains_key(name) { Ok(()) } else { Err(CheckError::UnknownType(name.clone())) diff --git a/crates/ailang-codegen/src/lib.rs b/crates/ailang-codegen/src/lib.rs index 094a0a8..f7618a8 100644 --- a/crates/ailang-codegen/src/lib.rs +++ b/crates/ailang-codegen/src/lib.rs @@ -154,7 +154,7 @@ pub fn lower_workspace(ws: &Workspace) -> Result { // Globals: per module, alphabetically over module names (BTreeMap order), // then insertion order per module. let mut emitted_global = false; - for (_mname, entries) in &all_strings { + for entries in all_strings.values() { for (name, content) in entries { let escaped = ll_string_literal(content); let len = c_byte_len(content); @@ -1086,7 +1086,6 @@ impl<'a> Emitter<'a> { &mut captures_set, &builtins, &top_level, - &self.import_map, ); // Outer scope provides every capture as a local — assert and @@ -1251,7 +1250,6 @@ impl<'a> Emitter<'a> { captures_set: &mut BTreeSet, builtins: &BTreeSet<&str>, top_level: &BTreeSet, - import_map: &BTreeMap, ) { match t { Term::Lit { .. } => {} @@ -1273,36 +1271,36 @@ impl<'a> Emitter<'a> { } } Term::App { callee, args } => { - Self::collect_captures(callee, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(callee, bound, captures, captures_set, builtins, top_level); for a in args { - Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(a, bound, captures, captures_set, builtins, top_level); } } Term::Let { name, value, body } => { - Self::collect_captures(value, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(value, bound, captures, captures_set, builtins, top_level); let inserted = bound.insert(name.clone()); - Self::collect_captures(body, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(body, bound, captures, captures_set, builtins, top_level); if inserted { bound.remove(name); } } Term::If { cond, then, else_ } => { - Self::collect_captures(cond, bound, captures, captures_set, builtins, top_level, import_map); - Self::collect_captures(then, bound, captures, captures_set, builtins, top_level, import_map); - Self::collect_captures(else_, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(cond, bound, captures, captures_set, builtins, top_level); + Self::collect_captures(then, bound, captures, captures_set, builtins, top_level); + Self::collect_captures(else_, bound, captures, captures_set, builtins, top_level); } Term::Do { args, .. } => { for a in args { - Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(a, bound, captures, captures_set, builtins, top_level); } } Term::Ctor { args, .. } => { for a in args { - Self::collect_captures(a, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(a, bound, captures, captures_set, builtins, top_level); } } Term::Match { scrutinee, arms } => { - Self::collect_captures(scrutinee, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(scrutinee, bound, captures, captures_set, builtins, top_level); for arm in arms { let mut pat_bindings = Vec::new(); Self::pattern_bound_names(&arm.pat, &mut pat_bindings); @@ -1312,7 +1310,7 @@ impl<'a> Emitter<'a> { newly_bound.push(n.clone()); } } - Self::collect_captures(&arm.body, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(&arm.body, bound, captures, captures_set, builtins, top_level); for n in newly_bound { bound.remove(&n); } @@ -1327,14 +1325,14 @@ impl<'a> Emitter<'a> { newly_bound.push(p.clone()); } } - Self::collect_captures(body, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(body, bound, captures, captures_set, builtins, top_level); for n in newly_bound { bound.remove(&n); } } Term::Seq { lhs, rhs } => { - Self::collect_captures(lhs, bound, captures, captures_set, builtins, top_level, import_map); - Self::collect_captures(rhs, bound, captures, captures_set, builtins, top_level, import_map); + Self::collect_captures(lhs, bound, captures, captures_set, builtins, top_level); + Self::collect_captures(rhs, bound, captures, captures_set, builtins, top_level); } } } @@ -1546,7 +1544,7 @@ fn builtin_binop(name: &str) -> Option<(&'static str, &'static str)> { } fn c_byte_len(s: &str) -> usize { - s.as_bytes().len() + 1 // + NUL + s.len() + 1 // + NUL terminator } /// Escapes a string for LLVM IR `c"..."`. All bytes outside