Add positional_count field to Lambda

This field is used for static optimization, determining if parameters
are purely positional.
This commit is contained in:
Michael Schimmel
2026-02-20 14:40:56 +01:00
parent 56d6c3bbde
commit 4e812c1afb
11 changed files with 361 additions and 62 deletions
+3 -2
View File
@@ -75,15 +75,16 @@ impl TCO {
}
},
BoundKind::Lambda { params, upvalues, body } => {
BoundKind::Lambda { params, upvalues, body, positional_count } => {
// The body of a lambda is implicitly in tail position when the lambda is called.
let new_body = Rc::new(Self::transform((*body).clone(), true));
Node {
kind: BoundKind::Lambda {
params,
params: params.clone(),
upvalues,
body: new_body,
positional_count,
},
..node
}