From 1e42e68098ab968c6130118fcf7dc1efdf103c05 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 30 May 2016 14:08:42 -0700 Subject: [PATCH] Handle cases where both valid and incomplete reduction paths end at the same stack node --- src/runtime/stack.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/runtime/stack.c b/src/runtime/stack.c index c8458dac..ee4bf0f1 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -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; }