Closed SimonMeskens closed 6 years ago
I've narrowed down the issue to the fact that cloneList
in values.ts doesn't copy the _left
and _right
Views, it just passes them. I think that's a bug? Separate lists shouldn't share View objects I think.
In deleteValues
in values.ts, we find the following lines (68 - 71):
var right = cloneList(list, nextId(), true);
sliceList(list, 0, start);
sliceList(right, end, right._size);
list = concatLists(list, right);
If the list is mutable, right
and list
share their Views and Slots, so that slice and concat doesn't work. I can fix it in deleteValues
, but I'm not sure what the use of a clone operator is, if it shares Views and Slots, so I think it's actually cloneList
that needs fixing.
ugh, scratch that, that's not the issue it seems. I'm at a loss what is.
The first remove always works, but the second one fails
You definitely picked the most complicated structure to attack! Overcomplicated even, as per what we discussed earlier.
Your first code sample is puzzling because you appear to be deleting elements in ascending order without accounting for the decreased size of the list during each subsequent operation. Operations are immediate, the commit
nomenclature does not imply latebound resolution or anything like that, it simply flips the mutation flag to "frozen". On that note, you don't need to use the return value of the commit
function; it's just provided as a convenience when used as the last call of a function that returns the modified collection instance.
Let me know if that changes your test case at all, and then I'll take a look and see if I can find the cause of the problem.
Yeah, I was trying a bunch of things figuring out what went wrong, so the example got a bit daft, but I swear I know what I'm doing ;)
Maybe I'll make a PR with my finalized code and we can have a look at a real example, but there's definitely a bug somewhere, as far as I can tell, due to ghosted changes in values.ts, lines (68 - 71)
If you write a test case and make a preliminary PR which can remain pending until we get the test to pass, I will sync the PR locally and help figure out the problem.
are you still experiencing issues with this? If not, I'll go ahead and close it.
I think there's something wrong with List.remove:
Output: