Handle cases where both valid and incomplete reduction paths end at the same stack node

This commit is contained in:
Max Brunsfeld 2016-05-30 14:08:42 -07:00
parent ea47fdc0fe
commit 1e42e68098

View file

@ -403,11 +403,13 @@ StackPopResult ts_stack_pop_count(Stack *self, StackVersion version,
if (pop.status && session.found_error) {
if (session.found_valid_path) {
StackSlice error_slice = pop.slices.contents[0];
ts_stack_remove_version(self, error_slice.version);
ts_tree_array_delete(&error_slice.trees);
array_erase(&pop.slices, 0);
for (StackVersion i = 0; i < pop.slices.size; i++)
pop.slices.contents[i].version--;
if (array_front(&pop.slices)->version != error_slice.version) {
ts_stack_remove_version(self, error_slice.version);
for (StackVersion i = 0; i < pop.slices.size; i++)
pop.slices.contents[i].version--;
}
} else {
pop.status = StackPopStoppedAtError;
}