Skip to content

Commit 0bbe0a6

Browse files
committed
fix: error reporting on update array merge function
1 parent b21bcf7 commit 0bbe0a6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

flake.nix

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,22 @@
192192
# ------
193193
update = indices: updates: orig: here: let
194194
inherit (builtins) length listToAttrs elemAt hasAttr;
195-
inherit (nixlib.lib) zipListsWith imap0 assertMsg traceSeqN;
195+
inherit (nixlib.lib) zipListsWith imap0 assertMsg traceSeqN setAttrByPath getAttrFromPath;
196196
in
197197
assert assertMsg (length indices == length updates) ''
198198
UPDATING ARRAY MERGE: for each index there must be one corresponding update value, got: ${traceSeqN 1 indices "(see first trace above)"} indices & ${traceSeqN 1 updates "(see second trace above)"} updates''; let
199199
updated = listToAttrs (
200200
zipListsWith (
201-
idx: upd: {
201+
idx: upd: let
202+
# manufacture a "here" for display purposes
203+
tmplhs = setAttrByPath (here ++ [(toString idx)]) (elemAt orig idx);
204+
tmprhs = setAttrByPath (here ++ [(toString idx)]) upd;
205+
in {
202206
name = toString idx;
203-
value =
204-
(
205-
mergeAt here
206-
{mergedListItem = elemAt orig idx;}
207-
{mergedListItem = upd;}
208-
)
209-
.mergedListItem;
207+
value = getAttrFromPath here (
208+
# but start from an empty here on this commissioned merge operation
209+
mergeAt [] tmplhs tmprhs
210+
);
210211
}
211212
)
212213
(list int indices)

0 commit comments

Comments
 (0)