genericClosure has very limited support for pointer equality: It relies on comparison (not equality!) in C++ Nix, so as soon as C++ Nix supports comparing lists (langVersion >= 6) we can rely on pointer equality for key. Since Tvix uses equality, not comparison for the insert, our behavior is currently different, as documented by the notyetpassing tests. Change-Id: Ifcd741ed4fc3ccc3825f7038875d56a9918b786a Reviewed-on: https://cl.tvl.fyi/c/depot/+/8720 Tested-by: BuildkiteCI Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su>
15 lines
449 B
Nix
15 lines
449 B
Nix
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? 🥺👉👈"; }
|
|
];
|
|
}
|