From 83e5f3b0d319c7f4d1f0bb85c39bbfe383d04637 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 15 Aug 2022 00:45:21 +0300 Subject: feat(tvix/eval): emit instructions to close `with` at scope end Change-Id: I340b7a0964a4d4c5be58f46d00d2376ec5682517 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6220 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: grfn --- tvix/eval/src/compiler.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tvix') diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs index 5edf83535b..cb568bfc6f 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>(&mut self, name: S) { -- cgit 1.4.1