about summary refs log blame commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-repeated-list-to-attrs.nix
blob: 2f719dcef5be207670072688342175865759c16f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                                          
# Ensure that builtins.listToAttrs returns the first instance of a key.

let
  inherit (builtins) foldl' listToAttrs;

  input = [ { name = "result"; value = 1; } { name = "result"; value = 2; } ];

  # foldl-based version of listToAttrs with the _opposite_ behaviour.
  listToAttrs' = list: foldl' ( acc: elem: acc // { ${elem.name} = elem.value; }) {} list;
in [
  (listToAttrs input).result
  (listToAttrs' input).result
]