fix(tvix/eval): account for attrset temporaries during construction

The temporaries left on the stack as operands to `OpAttrs` must be
accounted for in the locals array in order for operations within them
to receive correct slots.

Some test cases that were previously broken have been added.

Change-Id: Ib52b629bbdf7931f63fd45a45af1073022da923c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6468
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-09-06 17:44:32 +03:00 committed by tazjin
parent 12acb1e237
commit f68c76d07d
5 changed files with 68 additions and 2 deletions

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,7 @@
# Creates a `with` across multiple thunk boundaries.
let
set = {
a = with { b = 42; }; b;
};
in set.a

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,12 @@
# Tests correct tracking of stack indices within construction of an
# attribute set. Dynamic keys can be any expression, so something that
# is extremely sensitive to stack offsets (like `with`) can be tricky.
let
set1 = { key = "b"; };
set2 = {
a = 20;
${with set1; key} = 20;
${with { key = "c"; }; key} = 2;
};
in set2.a + set2.b + set2.c