From 13a5e7dd5ba6a5e448390e5ceb7f41825e7593c2 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 17 Oct 2022 17:51:38 +0300 Subject: fix(tvix/eval): wrap dynamic resolution in an extra thunk Without this change it was possible to cause situations (see the new test) in which a `with`-namespace was forced prematurely. Change-Id: I879ea7763b43edc693feace2c73c890d426fafd3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7031 Autosubmit: tazjin Tested-by: BuildkiteCI Reviewed-by: Adam Joseph --- tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.nix | 5 +++++ tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with.nix | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.exp new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.exp @@ -0,0 +1 @@ +42 diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.nix new file mode 100644 index 0000000000..22ac14b3f1 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with-nested.nix @@ -0,0 +1,5 @@ +# The 'namespace' of a with should only be evaluated if an identifier +# from it is actually accessed. + +with (abort "should not be evaluated"); +let a = dynamic; in 42 diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with.nix index e4377df97e..8b1a0191dc 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with.nix +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-lazy-with.nix @@ -1,6 +1,6 @@ # The 'namespace' of a with should only be evaluated if an identifier # from it is actually accessed. -with (builtins.throw "should not occur"); +with (abort "should not be evaluated"); 42 -- cgit 1.4.1