Add 'again' keyword for recursive calls
The `again` keyword is introduced to facilitate explicit recursive function calls. It is restricted to tail-call positions to prevent dead code and ensure TCO optimization. Type checking is enhanced to validate argument types against function parameters.
This commit is contained in:
@@ -123,6 +123,15 @@ impl<'a> Analyzer<'a> {
|
||||
(BoundKind::Call { callee: Box::new(callee_m), args: Box::new(args_m) }, p)
|
||||
}
|
||||
|
||||
BoundKind::Again { args } => {
|
||||
let args_m = self.visit(Rc::new((**args).clone()));
|
||||
if let Some(lambda_id) = self.lambda_stack.last() {
|
||||
self.recursive_identities.insert(lambda_id.clone());
|
||||
is_recursive = true;
|
||||
}
|
||||
(BoundKind::Again { args: Box::new(args_m) }, Purity::Impure)
|
||||
}
|
||||
|
||||
BoundKind::Block { exprs } => {
|
||||
let mut new_exprs = Vec::with_capacity(exprs.len());
|
||||
let mut p = Purity::Pure;
|
||||
|
||||
Reference in New Issue
Block a user