From f995aaf81b3187a6810e57966182b42642f136de Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Wed, 25 Feb 2026 09:59:23 +0100 Subject: [PATCH] Formatting --- src/ast/compiler/optimizer.rs | 11 +++++++++-- src/ast/compiler/type_checker.rs | 13 +++++++++---- src/ast/vm.rs | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ast/compiler/optimizer.rs b/src/ast/compiler/optimizer.rs index f7b8279..bbabb6d 100644 --- a/src/ast/compiler/optimizer.rs +++ b/src/ast/compiler/optimizer.rs @@ -783,7 +783,8 @@ impl Optimizer { self.collect_parameter_slots_set(params, &mut param_slots); for slot in param_slots { - if (body_usage.used_locals.contains(&slot) || body_usage.assigned_locals.contains(&slot)) + if (body_usage.used_locals.contains(&slot) + || body_usage.assigned_locals.contains(&slot)) && !sub.locals.contains_key(&slot) && !sub.ast_locals.contains_key(&slot) { @@ -881,7 +882,13 @@ impl Optimizer { // Match inner elements against the flattened compound argument let mut sub_offset = 0; for el in elements { - self.map_params_to_args(el, &sub_args, &mut sub_offset, sub, body_usage); + self.map_params_to_args( + el, + &sub_args, + &mut sub_offset, + sub, + body_usage, + ); } *offset += 1; return; diff --git a/src/ast/compiler/type_checker.rs b/src/ast/compiler/type_checker.rs index 3e6c7d7..10193ee 100644 --- a/src/ast/compiler/type_checker.rs +++ b/src/ast/compiler/type_checker.rs @@ -208,9 +208,10 @@ impl TypeChecker { StaticType::Vector(inner, _) => (**inner).clone(), StaticType::Matrix(inner, _) => (**inner).clone(), // Matrix flat iteration or row? Wait. Matrix destructuring logic is tricky. But for now let's focus on Record. StaticType::List(inner) => (**inner).clone(), - StaticType::Record(fields) => { - fields.get(i).map(|(_, ty)| ty.clone()).unwrap_or(StaticType::Any) - } + StaticType::Record(fields) => fields + .get(i) + .map(|(_, ty)| ty.clone()) + .unwrap_or(StaticType::Any), _ => StaticType::Any, }; let t = self.check_params(el, &sub_ty, ctx)?; @@ -622,7 +623,11 @@ mod tests { // fn takes 1 arg, called with 0 let result = env.compile("(do (def f (fn [x] x)) (f))"); assert!(result.is_err()); - assert!(result.unwrap_err().contains("Invalid arguments for function call")); + assert!( + result + .unwrap_err() + .contains("Invalid arguments for function call") + ); } #[test] diff --git a/src/ast/vm.rs b/src/ast/vm.rs index ab23eb4..47db089 100644 --- a/src/ast/vm.rs +++ b/src/ast/vm.rs @@ -417,7 +417,9 @@ impl VM { self.stack.extend(arg_vals); } else { // Map each parameter pattern to the provided arguments - if let BoundKind::Tuple { elements } = &closure.parameter_node.kind { + if let BoundKind::Tuple { elements } = + &closure.parameter_node.kind + { let mut offset = 0; for el in elements { self.unpack(el, &arg_vals, &mut offset)?;