Refactor: Pass global names to Binder

The `Binder` struct now accepts a `Rc<RefCell<HashMap<Symbol,
(GlobalIdx, Identity)>>>` for global names. This allows the binder to
directly access and manage global symbols during the binding process,
simplifying the logic and improving efficiency.

Additionally, `CompilerScope` now implements `Default`, and a type alias
`BindingResult` has been introduced for clarity. The `bind_root`
function signature has been updated to accept the `globals` argument.
This commit is contained in:
Michael Schimmel
2026-03-12 16:21:20 +01:00
parent a220815bd6
commit dcb7685d29
4 changed files with 86 additions and 28 deletions
+3 -3
View File
@@ -783,7 +783,7 @@ mod tests {
let mut diag = crate::ast::diagnostics::Diagnostics::new();
// fixed_scope_idx = 0 means scope 0 is frozen (Global)
let result = Binder::bind_root(initial_scopes, 1, 0, &expanded, &mut diag);
let result = Binder::bind_root(initial_scopes, 1, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
assert!(
result.is_ok(),
"Should find global '*' Error: {:?}",
@@ -807,7 +807,7 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
assert!(result.is_ok(), "Hygiene failed: {:?}", result.err());
}
@@ -827,7 +827,7 @@ mod tests {
let expanded = expander.expand(untyped).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
let result = Binder::bind_root(vec![], 0, 0, Rc::new(RefCell::new(HashMap::new())), &expanded, &mut diag);
assert!(
result.is_ok(),
"Explicit Hygiene with Backticks failed: {:?}",