fix bug in dict comparison

This commit is contained in:
Joeri Exelmans 2025-06-16 13:17:10 +02:00
parent 41a5335d87
commit 5d028fe030
3 changed files with 39 additions and 7 deletions

View file

@ -77,8 +77,10 @@ export const compareDicts = compareKeys => compareValues => x => y => {
// because of the underlying red-black tree, iteration happens in ordered fashion
const iterate = iterX => iterY =>
match(readDict(iterX))
(entryX =>
(_ => 0) // end of iteration (dicts are equal)
(entryX => // entry...
match(readDict(iterY))
(_ => {throw new Error("this can never happen");})
(entryY => compareKeys
(getLeft(getLeft(entryX)))
(getLeft(getLeft(entryY)))
@ -87,9 +89,9 @@ export const compareDicts = compareKeys => compareValues => x => y => {
(getRight(getLeft(entryY)))
|| iterate
(getRight(entryX))
(getRight(entryY)))
(_ => 0))
(_ => 0); // we made it, dicts are equal
(getRight(entryY))
)
);
return iterate(firstDict(x))(firstDict(y));
})();
};