Formatting
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
+3
-1
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user