From d1b7e0872608b2d78ddcb2ee473ec9bdbf9695a8 Mon Sep 17 00:00:00 2001 From: sterni Date: Fri, 15 Mar 2024 14:36:34 +0100 Subject: fix(tvix/eval): don't force lambda arg in map, mapAttrs & genList It is pretty pointless to force the function argument if we are going to use a suspended call later since forcing the function may fail in ways that are not covered by Catchables (non-recoverable errors, infinite recursions). From this, it kind of seems as if using #[catch] is never correct and should be replaced by #[lazy]. Also we should probably try to come up with more test cases for stuff where laziness gets us out of the jam as an equivalent to the catchable tests for nonrecoverable errors. Fixes b/386. Change-Id: Ia926df4ac1b440ec430403ab7b40924a0c97221b Reviewed-on: https://cl.tvl.fyi/c/depot/+/11153 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: sterni --- .../tvix_tests/eval-okay-builtins-genList-function-strictness.exp | 1 + .../tvix_tests/eval-okay-builtins-genList-function-strictness.nix | 8 ++++++++ .../tvix_tests/eval-okay-builtins-map-function-strictness.exp | 1 + .../tvix_tests/eval-okay-builtins-map-function-strictness.nix | 8 ++++++++ .../eval-okay-builtins-mapAttrs-function-strictness.exp | 1 + .../eval-okay-builtins-mapAttrs-function-strictness.nix | 8 ++++++++ 6 files changed, 27 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.nix create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.nix create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.exp new file mode 100644 index 000000000000..06712ebc33e4 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.exp @@ -0,0 +1 @@ +[ 0 1 2 ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.nix new file mode 100644 index 000000000000..e161e3b4af4f --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genList-function-strictness.nix @@ -0,0 +1,8 @@ +let + self = + let + l = builtins.genList (builtins.head self) 3; + in + [ (x: x) ] ++ l; +in +self diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.exp new file mode 100644 index 000000000000..050c2c4de51f --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.exp @@ -0,0 +1 @@ +[ 2 "." 18 "https://github.com/NixOS/nix/issues/9779" "-.-" ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.nix new file mode 100644 index 000000000000..932d3d0eaebc --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map-function-strictness.nix @@ -0,0 +1,8 @@ +let + self = + let + l = builtins.map (builtins.head self) [ 2 "." 18 https://github.com/NixOS/nix/issues/9779 "-.-" ]; + in + [ (x: x) ] ++ l; +in +self diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.exp new file mode 100644 index 000000000000..7e70748ffd6f --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.exp @@ -0,0 +1 @@ +{ a = 1; b = 2; f = ; } diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.nix new file mode 100644 index 000000000000..2946d6de1760 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-mapAttrs-function-strictness.nix @@ -0,0 +1,8 @@ +let + self = + let + s = builtins.mapAttrs self.f { a = 1; b = 2; }; + in + { f = _: x: x; } // s; +in +self -- cgit 1.4.1