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:
+1
-2
@@ -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)) => (),
|
||||
|
||||
Reference in New Issue
Block a user