be aware of temporary variables of stackless iterator in term_variables
@@ -4905,12 +4905,17 @@ pub(crate) fn term_variables(&mut self) {
let mut seen_set = IndexSet::new();
{
+ let orig_heap_len = self.machine_st.heap.len();
let mut iter = stackless_preorder_iter(&mut self.machine_st.heap, stored_v);
while let Some(addr) = iter.next() {
let addr = unmark_cell_bits!(addr);
- if addr.is_var() {
+ if addr.is_var() && addr.get_value() < orig_heap_len {
+ // the length check is so we don't catalog
+ // temporary variables created by the iterator,
+ // that will be deleted when the iterator is
+ // dropped, into seen_set.
seen_set.insert(addr);
}
}
