about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r--tvix/eval/src/compiler/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 85a2309eb3..458c7b4328 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -844,6 +844,7 @@ impl Compiler {
                     // and can be finalised.
                     if slot.unwrap() < idx.0 {
                         self.chunk().push_op(OpCode::DataDeferredLocal(idx));
+                        self.mark_needs_finaliser(slot.unwrap());
                     } else {
                         self.chunk().push_op(OpCode::DataLocalIdx(idx));
                     }
@@ -987,6 +988,7 @@ impl Compiler {
             name,
             depth,
             initialised: false,
+            needs_finaliser: false,
             node: Some(node),
             phantom: false,
             used: false,
@@ -1002,6 +1004,7 @@ impl Compiler {
         self.scope_mut().locals.push(Local {
             depth,
             initialised: true,
+            needs_finaliser: false,
             name: "".into(),
             node: None,
             phantom: true,
@@ -1014,6 +1017,11 @@ impl Compiler {
         self.scope_mut().locals[local_idx].initialised = true;
     }
 
+    /// Mark local as needing a finaliser.
+    fn mark_needs_finaliser(&mut self, local_idx: usize) {
+        self.scope_mut().locals[local_idx].needs_finaliser = true;
+    }
+
     fn resolve_upvalue(&mut self, ctx_idx: usize, name: &str) -> Option<UpvalueIdx> {
         if ctx_idx == 0 {
             // There can not be any upvalue at the outermost context.