fix list copying
@@ -71,13 +71,31 @@ fn copy_list(&mut self, addr: usize) {
*self.value_at_scan() = HeapCellValue::Addr(Addr::Lis(threshold));
let hcv = self.target[addr].clone();
+
+ let ra = hcv.as_addr(threshold);
+ let rd = self.target.store(self.target.deref(ra));
+
self.target.push(hcv);
let hcv = self.target[addr + 1].clone();
self.target.push(hcv);
+ match rd.clone() {
+ Addr::AttrVar(h) | Addr::HeapCell(h) if h >= self.old_h => {
+ self.target[threshold] = HeapCellValue::Addr(rd)
+ }
+ ra @ Addr::AttrVar(_) | ra @ Addr::HeapCell(..) | ra @ Addr::StackCell(..) => {
+ if ra == rd {
+ self.reinstantiate_var(ra, threshold);
+ } else {
+ self.target[threshold] = HeapCellValue::Addr(ra);
+ }
+ }
+ _ => {
self.trail.push((Ref::HeapCell(addr), self.target[addr].clone()));
- self.target[addr] = HeapCellValue::Addr(Addr::Lis(threshold));
+ self.target[addr] = HeapCellValue::Addr(Addr::Lis(threshold))
+ }
+ };
self.scan += 1;
}
