Refactor: Remove explicit upvalue analysis pass

The `UpvalueAnalyzer` pass is no longer necessary as the binder now
directly tracks captures. This commit removes the `UpvalueAnalyzer`
struct and associated logic from `src/ast/compiler/upvalues.rs`.

The `Binder::bind_root` function now returns the `captures` map, which
is then processed by a new `CapturePass` in `src/ast/environment.rs`
before type checking. This consolidates capture logic within the binder
and its subsequent processing steps.
This commit is contained in:
Michael Schimmel
2026-02-25 12:15:59 +01:00
parent 82daf03522
commit 0371c21523
5 changed files with 92 additions and 204 deletions
+14 -6
View File
@@ -713,7 +713,15 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let mut global_names = HashMap::new();
global_names.insert(Symbol::from("*"), 0);
global_names.insert(
Symbol::from("*"),
(
0,
Rc::new(crate::ast::types::NodeIdentity {
location: crate::ast::types::SourceLocation { line: 0, col: 0 },
}),
),
);
let globals = Rc::new(RefCell::new(global_names));
let result = Binder::bind_root(globals, &expanded);
@@ -740,8 +748,8 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let globals = Rc::new(RefCell::new(HashMap::new()));
let bound = Binder::bind_root(globals, &expanded);
assert!(bound.is_ok(), "Hygiene failed: {:?}", bound.err());
let result = Binder::bind_root(globals, &expanded);
assert!(result.is_ok(), "Hygiene failed: {:?}", result.err());
}
#[test]
@@ -760,11 +768,11 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let globals = Rc::new(RefCell::new(HashMap::new()));
let bound = Binder::bind_root(globals, &expanded);
let result = Binder::bind_root(globals, &expanded);
assert!(
bound.is_ok(),
result.is_ok(),
"Explicit Hygiene with Backticks failed: {:?}",
bound.err()
result.err()
);
}
}