From: Mark Thom Date: Fri, 12 Jun 2020 03:25:20 +0000 (-0600) Subject: adjust the tail created by CreatePartialString to point to the last cell it pushed... X-Git-Tag: v0.8.127~42 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=d9de38b9359facf3babfe54a512399d3cb78cc5e;p=scryer-prolog.git adjust the tail created by CreatePartialString to point to the last cell it pushed to the heap (#586) --- diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index d4607c59..3c50c079 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -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); } }