about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-14T21·45+0300
committertazjin <tazjin@tvl.su>2022-08-31T22·26+0000
commit83e5f3b0d319c7f4d1f0bb85c39bbfe383d04637 (patch)
treeaa82b9735f9297b117c8d30465881bdb31f3cd3d /tvix
parent19878c5fef1f8bb1c051083a30616d4738d637e4 (diff)
feat(tvix/eval): emit instructions to close `with` at scope end r/4554
Change-Id: I340b7a0964a4d4c5be58f46d00d2376ec5682517
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6220
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix')
-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) {