]> Repositorios git - scryer-prolog.git/commitdiff
correct threshold marking in copy_structure (#2920)
authorMark Thom <[email protected]>
Sun, 4 May 2025 05:04:04 +0000 (22:04 -0700)
committerMark Thom <[email protected]>
Tue, 8 Jul 2025 05:38:12 +0000 (22:38 -0700)
src/machine/copier.rs

index 57e034af16c53bf9b588c3bf48a3187e5abaf5c6..78658c4a9d67c13fa2b543f3098b067179c8cfc7 100644 (file)
@@ -426,7 +426,7 @@ impl<T: CopierTarget> CopyTermState<T> {
 
                 let index_cell = self.target[addr.saturating_sub(1)];
 
-                *self.value_at_scan() = if get_structure_index(index_cell).is_some() {
+                let str_cell = if get_structure_index(index_cell).is_some() {
                     // copy the index pointer trailing this
                     // inlined or expanded goal.
                     let mut writer = self.target.reserve(1).unwrap();
@@ -440,11 +440,12 @@ impl<T: CopierTarget> CopyTermState<T> {
                     str_loc_as_cell!(threshold)
                 };
 
+                *self.value_at_scan() = str_cell;
                 self.target.copy_slice_to_end(addr .. addr + 1 + arity)?;
 
                 let trail_item = mem::replace(
                     &mut self.target[addr],
-                    str_loc_as_cell!(threshold),
+                    str_cell,
                 );
 
                 self.trail.push((TrailRef::heap_cell(addr), trail_item));