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:
@@ -289,6 +289,19 @@ impl Binder {
|
||||
))
|
||||
}
|
||||
|
||||
UntypedKind::Again { args } => {
|
||||
if self.functions.len() <= 1 {
|
||||
return Err("'again' is only allowed inside a function or lambda.".to_string());
|
||||
}
|
||||
let args = self.bind(args)?;
|
||||
Ok(self.make_node(
|
||||
node.identity.clone(),
|
||||
BoundKind::Again {
|
||||
args: Box::new(args),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
UntypedKind::Block { exprs } => {
|
||||
let mut bound_exprs = Vec::new();
|
||||
for expr in exprs {
|
||||
|
||||
Reference in New Issue
Block a user