Skip to content

Commit

Permalink
First pass at a fix for guidance-ai#863
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-ai committed Jun 2, 2024
1 parent c009b1a commit f17e434
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion guidance/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,14 @@ def _record_captures_from_root(self, initial_item, data, log_prob_data):

def _compute_parse_tree(self, initial_pos, initial_item, reversed_state_sets):
stack = [(initial_pos, initial_item)]
seen = set()

while stack:
pos, item = stack.pop()

if (pos, item) in seen:
# Skip items we have already processed
continue
seen.add((pos, item))
# compute the children for this item
assert self._compute_children(pos, item, reversed_state_sets)

Expand Down

0 comments on commit f17e434

Please sign in to comment.