]> Repositorios git - scryer-prolog.git/commitdiff
build partial strings using PStrLoc in write_term_to_heap (#1627)
authorMark Thom <[email protected]>
Sun, 23 Oct 2022 22:30:41 +0000 (16:30 -0600)
committerMark Thom <[email protected]>
Thu, 27 Oct 2022 05:36:07 +0000 (23:36 -0600)
src/read.rs

index b4176c55826748ecbacbbd7915c20fe6ad4c2ca2..c8743c2f35ee89568747468a3b4aea9f0701917b 100644 (file)
@@ -390,6 +390,12 @@ impl<'a, 'b> TermWriter<'a, 'b> {
                     put_complete_string(self.heap, src.as_str(), self.atom_tbl);
                 }
                 &TermRef::PartialString(lvl, _, ref src, _) => {
+                    if let Level::Root = lvl {
+                        // Var tags can't refer directly to partial strings,
+                        // so a PStrLoc cell must be pushed.
+                        self.heap.push(pstr_loc_as_cell!(heap_loc + 1));
+                    }
+
                     allocate_pstr(self.heap, src.as_str(), self.atom_tbl);
 
                     let h = self.heap.len();