From 3b6169f87be45c77ec4b56d118a5e2c718ff3f2b Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 22 Sep 2023 12:22:04 +0200 Subject: lib.lists.foldl': Make strict in the initial accumulator To maintain backwards compatibility, this can't be changed in the Nix language. We can however ensure that the version Nixpkgs has the more intuitive behavior. --- lib/tests/misc.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/tests/misc.nix') diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 50d615c5be38..d40d92049880 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -524,10 +524,10 @@ runTests { expected = [ 3 2 1 ]; }; - # The same as builtins.foldl', lib.foldl' doesn't evaluate the first accumulator strictly + # Compared to builtins.foldl', lib.foldl' evaluates the first accumulator strictly too testFoldl'StrictInitial = { expr = (builtins.tryEval (foldl' (acc: el: el) (throw "hello") [])).success; - expected = true; + expected = false; }; # Make sure we don't get a stack overflow for large lists -- cgit 1.4.1