diff options
author | sterni <sternenseemann@systemli.org> | 2022-10-15T13·52+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-10-15T14·12+0000 |
commit | f3c27f1717f0b92b05340c0bc6ba44007ce9d90b (patch) | |
tree | 989566dc26387d1e7849df4de0bdc841cdf963aa /tvix/eval/src/tests/tvix_tests | |
parent | caf9cbf71147054c01c6fdf49773d646cbfb46eb (diff) |
fix(tvix/eval): bring foldl' strictness in line with C++ Nix r/5133
Working on https://github.com/NixOS/nix/pull/7158, I discovered that C++ Nix actually is strict in the accumulator, just not in the first value. This seems due to the fact that in the C++ evaluator, function calls don't seem to be thunked unconditionally and foldl' just elects not to wrap it in a thunk (don't quote me on this summary, even though it seems to line up with the code for primop_foldlStrict and testable behavior). It doesn't seem worth it to risk breaking the odd Nix expression just to be strict in one more value per invocation of foldl' (i.e. the initial accumulator value `nul`), so let's match the existing C++ Nix behavior here. Change-Id: If59e62271a90d97cb440f0ca72a58ec7840d1690 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7022 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/tests/tvix_tests')
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-fail-foldlStrict-strict-op-application.nix | 4 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.exp | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.nix | 4 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.exp (renamed from tvix/eval/src/tests/tvix_tests/eval-okay-foldl.exp) | 0 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.nix (renamed from tvix/eval/src/tests/tvix_tests/eval-okay-foldl.nix) | 0 |
5 files changed, 9 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-foldlStrict-strict-op-application.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-foldlStrict-strict-op-application.nix new file mode 100644 index 000000000000..adc029b2f29e --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-fail-foldlStrict-strict-op-application.nix @@ -0,0 +1,4 @@ +builtins.foldl' + (_: f: f null) + (throw "This doesn't explode") + [ (_: throw "Not the final value, but is still forced!") (_: 23) ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.exp new file mode 100644 index 000000000000..d81cc0710eb6 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.exp @@ -0,0 +1 @@ +42 diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.nix new file mode 100644 index 000000000000..59fd29b55237 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict-lazy-initial-accumulator.nix @@ -0,0 +1,4 @@ +builtins.foldl' + (_: x: x) + (throw "This is never forced") + [ "but the results of applying op are" 42 ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-foldl.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.exp index 8d683a20fab7..8d683a20fab7 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-foldl.exp +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.exp diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-foldl.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.nix index 44c0349387ff..44c0349387ff 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-foldl.nix +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-foldlStrict.nix |