From d9de38b9359facf3babfe54a512399d3cb78cc5e Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Thu, 11 Jun 2020 21:25:20 -0600 Subject: [PATCH] adjust the tail created by CreatePartialString to point to the last cell it pushed to the heap (#586) --- src/prolog/machine/system_calls.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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); } } -- 2.54.0