diff options
Diffstat (limited to 'tvix/eval/src')
-rw-r--r-- | tvix/eval/src/compiler/attrs.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.exp | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.nix | 5 |
3 files changed, 10 insertions, 2 deletions
diff --git a/tvix/eval/src/compiler/attrs.rs b/tvix/eval/src/compiler/attrs.rs index 1584d5017aa2..5dee3a905d01 100644 --- a/tvix/eval/src/compiler/attrs.rs +++ b/tvix/eval/src/compiler/attrs.rs @@ -270,13 +270,15 @@ impl Compiler<'_> { // Push the set onto the stack self.compile(slot, set.clone()); - self.emit_force(&set); // Compile each key fragment and emit access instructions. // // TODO: multi-select instruction to avoid re-pushing attrs on // nested selects. for fragment in path.attrs() { + // Force the current set value. + self.emit_force(&fragment); + self.compile_attr(slot, fragment.clone()); self.push_op(OpCode::OpAttrsSelect, &fragment); } @@ -319,10 +321,10 @@ impl Compiler<'_> { default: ast::Expr, ) { self.compile(slot, set.clone()); - self.emit_force(&set); let mut jumps = vec![]; for fragment in path.attrs() { + self.emit_force(&fragment); self.compile_attr(slot, fragment.clone()); self.push_op(OpCode::OpAttrsTrySelect, &fragment); jumps.push(self.push_op(OpCode::OpJumpIfNotFound(JumpOffset(0)), &fragment)); diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.exp new file mode 100644 index 000000000000..d81cc0710eb6 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.exp @@ -0,0 +1 @@ +42 diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.nix new file mode 100644 index 000000000000..f3ad8293540f --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-nested-set-thunks.nix @@ -0,0 +1,5 @@ +({ + x = { + y = 42; + }; +}).x.y |