diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-27T16·33+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-04T17·40+0000 |
commit | 27bc8cb3d4f4274dd45c810d8d1a789076bcb9f5 (patch) | |
tree | ed4858b6f838f6457ccfd0b4da6bb77b3c03230f /tvix/eval/src | |
parent | abd8f12f5dbeece2d8d3779be4b499ff1f11680e (diff) |
fix(tvix/eval): open/close additional scope around `with` r/4639
This is required to correctly clean up the `with` values. At the moment, the attrset from which identifiers are being taken is always pushed on the stack. This means that it must also be removed again, otherwise in an expression like with { a = 15; }; a The final stack is `[ { a = 15; } 15 ]` *after the last operation*, which means that the attrset is still on there as garbage. This has little practical impact right now because it is always shadowed by the fact that the actual expression value is at the right location, but becomes relevant when accounting for upvalue captures. Change-Id: I69e9745bfaa4d6bbcb60ee71f4dc3f8d8695d16a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6303 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 6f48e8f3d5ba..928d39bae595 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -885,6 +885,7 @@ impl Compiler { // pop/remove the indices of attribute sets that are implicitly in // scope through `with` on the "with-stack". fn compile_with(&mut self, node: ast::With) { + self.begin_scope(); // TODO: Detect if the namespace is just an identifier, and // resolve that directly (thus avoiding duplication on the // stack). @@ -900,6 +901,7 @@ impl Compiler { self.chunk().push_op(OpCode::OpPopWith); self.scope_mut().with_stack.pop(); + self.end_scope(); } fn compile_lambda(&mut self, node: ast::Lambda) { |