]> Repositorios git - scryer-prolog.git/commitdiff
adjust the tail created by CreatePartialString to point to the last cell it pushed...
authorMark Thom <[email protected]>
Fri, 12 Jun 2020 03:25:20 +0000 (21:25 -0600)
committerMark Thom <[email protected]>
Fri, 12 Jun 2020 03:25:20 +0000 (21:25 -0600)
src/prolog/machine/system_calls.rs

index d4607c59e988fe04ed690233fde10654ba8ea16c..3c50c0799940bd0f97d35bc1fc3ac04008de7535 100644 (file)
@@ -1079,19 +1079,18 @@ impl MachineState {
                     }
                 };
 
-                let h = self.heap.h();
-
                 if atom.as_str().is_empty() {
                     self.fail = true;
                     return Ok(());
                 }
 
                 let pstr = self.heap.allocate_pstr(atom.as_str());
-                let pstr_tail = self.heap[h + 1].as_addr(h + 1);
-
                 self.unify(self[temp_v!(2)], pstr);
 
                 if !self.fail {
+                    let h = self.heap.h();
+                    let pstr_tail = self.heap[h - 1].as_addr(h - 1);
+
                     self.unify(self[temp_v!(3)], pstr_tail);
                 }
             }