diff options
5 files changed, 38 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.exp new file mode 100644 index 000000000000..87977137a57b --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.exp @@ -0,0 +1 @@ +[ { key = [ { foo = <LAMBDA>; } ]; val = null; } ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.nix new file mode 100644 index 000000000000..5e662cdaf75e --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-genericClosure-pointer-equality.nix @@ -0,0 +1,15 @@ +let + foo = x: x; +in + +# key needs to be a list since it uses comparison, not equality checks: +# lists are comparable in Nix if all non-comparable items in them are equal (e.g. +# functions, attribute sets). +builtins.genericClosure { + startSet = [ + { key = [ { inherit foo; } ]; val = null; } + ]; + operator = { val, ... }: if val != null then [] else [ + { key = [ { inherit foo; } ]; val = throw "no pointer equality? π₯Ίππ"; } + ]; +} diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys.nix b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys.nix new file mode 100644 index 000000000000..d4e93e1f28c0 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys.nix @@ -0,0 +1,9 @@ +# Attribute sets can't be compared, only checked for equality +builtins.genericClosure { + startSet = [ + { key = { foo = 21; }; } + ]; + operator = _: [ + { key = { bar = 21; }; } + ]; +} diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys2.nix b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys2.nix new file mode 100644 index 000000000000..ca2825524546 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-fail-builtins-genericClosure-uncomparable-keys2.nix @@ -0,0 +1,12 @@ +let + id = x: x; +in + +builtins.genericClosure { + startSet = [ { key = id; first = true; } ]; + operator = + { first, ... }: + if first then [ + { key = id; first = false; } + ] else []; +} diff --git a/tvix/verify-lang-tests/default.nix b/tvix/verify-lang-tests/default.nix index ef67aeb48986..7e70b6230673 100644 --- a/tvix/verify-lang-tests/default.nix +++ b/tvix/verify-lang-tests/default.nix @@ -55,6 +55,7 @@ let "eval-okay-sort.nix" = [ nix ]; "eval-okay-compare-lists.nix" = [ nix ]; "eval-okay-value-pointer-compare.nix" = [ nix ]; + "eval-okay-builtins-genericClosure-pointer-equality.nix" = [ nix ]; # getAttrPos gains support for functionArgs-returned sets after 2.3 "eval-okay-getattrpos-functionargs.nix" = [ nix ]; # groupBy appeared (long) after 2.3 |