about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/eval/src/compiler.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs
index 5edf83535b67..cb568bfc6fbd 100644
--- a/tvix/eval/src/compiler.rs
+++ b/tvix/eval/src/compiler.rs
@@ -850,6 +850,13 @@ impl Compiler {
         if pops > 0 {
             self.chunk.push_op(OpCode::OpCloseScope(pops));
         }
+
+        while !scope.with_stack.is_empty()
+            && scope.with_stack[scope.with_stack.len() - 1].depth > scope.scope_depth
+        {
+            self.chunk.push_op(OpCode::OpPopWith);
+            scope.with_stack.pop();
+        }
     }
 
     fn push_local<S: Into<String>>(&mut self, name: S) {