Closed kellymclaughlin closed 5 years ago
Nice find, I'll try to dig into this properly soon and decide on a fix. At first glance your solution looks reasonable 👍 Please ping me if I get distracted!
I ended up opting for a more direct solution which covers more cases – the core of the issue was that the remove function was dropping the child node whenever it got a KeyMatch::Partial
or KeyMatch::FirstPrefix
. It now re-inserts the child correctly in these cases (so that the total effect of the remove is to do nothing).
There's a new release out that fixes the bug
Thanks @michaelsproul!
To demonstrate the issue I made the following change the
prefix
test case in thetest
module:Afterwards I get this failure:
Next, I added a call to
check_trie_integrity
like this:The resulting test failure looks like this:
So it seems that attempting to remove a key from the trie that doesn't exist in this manner has negative effect on the trie integrity.
I made the following change to the
traversal
module and it resolves the issue and all the tests pass (including my modifications):I don't know if that's a good fix or not, but I just noticed from adding
dbg
statements that the problem happened inrec_remove
when the result of thematch_keys
call wasKeyMatch::Partial
.