about summary refs log tree commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-14T11·38+0300
committertazjin <tazjin@tvl.su>2022-08-30T17·13+0000
commit3a67f912284e22f50bb54a6f6a533b2caf8929f8 (patch)
treea992353eb46445c37eb9a20abc3cad5d9942500c /tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix
parentcfe37d36f7977f93dd5b8441d691811bf2b6997b (diff)
fix(tvix/eval): `?` operator should use OpAttrsOrNotFound r/4544
Using `OpAttrSelect`, the ? operator will fail when encountering a
nested value that is not an attribute set.

This however breaks valid code, such as:

  { bs = 42; } ? bs.a.b

The fix is simply to use the same operator used in the `or` statement,
which leaves a sentinal on the stack if a field is not found or the
value is not an attribute set.

Change-Id: Ib28fc8a96e6d592b4cdbc3e65ba129ad8faecd66
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6211
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to '')
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix
new file mode 100644
index 0000000000..361ba91445
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-contains-nested-non-set.nix
@@ -0,0 +1,3 @@
+# ? operator should work even if encountering a non-set value on the
+# walk
+{ a.b = 42; } ? a.b.c