Refactor binder to use scope depth

Introduced `scope_depth` to the `Binder` to track block nesting. This
allows for correctly determining whether a `def` binding should be
`Address::Global` (at scope depth 0) or `Address::Local`.

The `type_checker` was also updated to handle `Program` and `Block`
nodes by creating a new `TypeContext` for them.

Removed the `wrap_as_lambda` method from `Environment` as the compiler
now always produces a `Program` node, effectively handling the wrapping
at the AST level. Correspondingly, `instantiate` and
`run_script_compiled` were simplified to directly run the `Program`
node.
This commit is contained in:
2026-03-31 15:22:51 +02:00
parent 8fd2f2d113
commit af8fb5cb7f
7 changed files with 43 additions and 124 deletions
+1 -2
View File
@@ -18,8 +18,7 @@ fn test_closure_modification_from_source() {
.into_result()
.expect("Failed to compile");
let linked = env.link(compiled);
let closure = env.instantiate(linked).expect("Failed to instantiate");
let result = env.create_vm().run_with_args(closure, &[]);
let result = env.create_vm().run(&linked);
match result {
Ok(Value::Int(20)) => (),