about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-22T16·29+0300
committertazjin <tazjin@tvl.su>2022-10-23T15·50+0000
commit9b52e5b9c2917bffc8405433a2c373a26cfe0c6e (patch)
tree072646bf5fa7ba331186da53d2d6cb9e17e1e635 /tvix
parent1f4420cb4aa3ad6e12af7784827f93c08cf008d8 (diff)
refactor(tvix/eval): simplify check for deferring upvalue resolution r/5182
This check is now actually simply equivalent to checking whether the
target has been initialised or not.

Change-Id: I30660d11073ba313358f3a64234a90ed81abf74c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7062
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/compiler/mod.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index cd2a669013..9c8f0078f3 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -996,20 +996,15 @@ impl Compiler<'_> {
         upvalues: Vec<Upvalue>,
         capture_with: bool,
     ) {
-        let this_depth = self.scope()[slot].depth;
-        let this_stack_slot = self.scope().stack_index(slot);
-
         for upvalue in upvalues {
             match upvalue.kind {
                 UpvalueKind::Local(idx) => {
-                    let target_depth = self.scope()[idx].depth;
+                    let target = &self.scope()[idx];
                     let stack_idx = self.scope().stack_index(idx);
 
-                    // If the upvalue slot is located at the same
-                    // depth, but *after* the closure, the upvalue
-                    // resolution must be deferred until the scope is
-                    // fully initialised and can be finalised.
-                    if this_depth == target_depth && this_stack_slot < stack_idx {
+                    // If the target is not yet initialised, we need to defer
+                    // the local access
+                    if !target.initialised {
                         self.push_op(OpCode::DataDeferredLocal(stack_idx), &upvalue.span);
                         self.scope_mut().mark_needs_finaliser(slot);
                     } else {