Skip to content

Commit fe7693d

Browse files
committed
Fix other cases where elements are poped
1 parent f441082 commit fe7693d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

dynamic_stack_decider/dynamic_stack_decider/dsd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ def update(self, reevaluate: bool = True):
259259
elif result != self.stack[self.stack_exec_index + 1][0].activation_reason:
260260
# In this case, however, the activation reason actually did change. Therefore, we have to
261261
# discard everything in the stack above the current decision and push the new result.
262-
self.stack = self.stack[0 : self.stack_exec_index + 1]
262+
for _ in range(self.stack_exec_index + 1, len(self.stack)):
263+
self.stack.pop()[1].on_pop()
263264
self.stack_reevaluate = False
264265
self.push(tree_element.get_child(result))
265266

dynamic_stack_decider/dynamic_stack_decider/sequence_element.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ def pop_one(self):
7373
# Return the popped action
7474
return popped_action
7575

76+
def on_pop(self):
77+
"""
78+
This method is called when the sequence is popped from the stack.
79+
This means that the last element of the sequence was also popped, so
80+
"""
81+
self.current_action.on_pop()
82+
7683
def in_last_element(self):
7784
"""Returns if the current element is the last element of the sequence"""
7885
return self.current_action_index == len(self.actions) - 1

0 commit comments

Comments
 (0)