Formatting
This commit is contained in:
@@ -411,7 +411,10 @@ impl Binder {
|
|||||||
// Global Definition in pattern
|
// Global Definition in pattern
|
||||||
let mut globals = self.globals.borrow_mut();
|
let mut globals = self.globals.borrow_mut();
|
||||||
if globals.contains_key(sym) {
|
if globals.contains_key(sym) {
|
||||||
return Err(format!("Global variable '{}' is already defined.", sym.name));
|
return Err(format!(
|
||||||
|
"Global variable '{}' is already defined.",
|
||||||
|
sym.name
|
||||||
|
));
|
||||||
}
|
}
|
||||||
let idx = globals.len() as u32;
|
let idx = globals.len() as u32;
|
||||||
globals.insert(sym.clone(), idx);
|
globals.insert(sym.clone(), idx);
|
||||||
|
|||||||
@@ -145,9 +145,7 @@ impl TypeChecker {
|
|||||||
(BoundKind::Parameter { name, slot }, specialized_ty.clone())
|
(BoundKind::Parameter { name, slot }, specialized_ty.clone())
|
||||||
}
|
}
|
||||||
BoundKind::DefGlobal {
|
BoundKind::DefGlobal {
|
||||||
name,
|
name, global_index, ..
|
||||||
global_index,
|
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
self.global_types
|
self.global_types
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|||||||
+4
-1
@@ -392,7 +392,10 @@ impl VM {
|
|||||||
}
|
}
|
||||||
Value::Function(f) => return Ok((f.func)(arg_vals)),
|
Value::Function(f) => return Ok((f.func)(arg_vals)),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(format!("Tail call target is not a function: {}", func_val));
|
return Err(format!(
|
||||||
|
"Tail call target is not a function: {}",
|
||||||
|
func_val
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,8 @@ mod tests {
|
|||||||
assert_eq!(format!("{}", env.run_script(source_global).unwrap()), "3");
|
assert_eq!(format!("{}", env.run_script(source_global).unwrap()), "3");
|
||||||
|
|
||||||
// 2. Local nested destructuring inside a function
|
// 2. Local nested destructuring inside a function
|
||||||
let source_local = "((fn [x] (do (def [a [[b c] d]] x) (+ a (+ b (+ c d))))) [1 [[2 3] 4]])";
|
let source_local =
|
||||||
|
"((fn [x] (do (def [a [[b c] d]] x) (+ a (+ b (+ c d))))) [1 [[2 3] 4]])";
|
||||||
assert_eq!(format!("{}", env.run_script(source_local).unwrap()), "10");
|
assert_eq!(format!("{}", env.run_script(source_local).unwrap()), "10");
|
||||||
|
|
||||||
// 3. Verify 'def' returns the assigned value
|
// 3. Verify 'def' returns the assigned value
|
||||||
|
|||||||
Reference in New Issue
Block a user