]> Repositorios git - scryer-prolog.git/commitdiff
FIXED: correct partial string tail calculation in arg/3
authorMarkus Triska <[email protected]>
Thu, 1 May 2025 07:18:00 +0000 (09:18 +0200)
committerMark Thom <[email protected]>
Tue, 8 Jul 2025 05:38:12 +0000 (22:38 -0700)
This addresses another aspect of #2924, found by @haijinSk.
Thank you again!

Example:

    ?- "aaaaaaa" = [_,_,_,_,_,_|T], arg(2, T, 2).
       false.

src/machine/machine_state_impl.rs

index baa2539413a6fd7c3fe83ffa10124ff26f3bb3d3..038a16d73e3982a8acd85ea31d6b6ab3b9355fef 100644 (file)
@@ -933,7 +933,7 @@ impl MachineState {
                                     if char_iter.next().is_some() {
                                         unify_fn!(*self, pstr_loc_as_cell!(pstr_loc + c.len_utf8()), a3);
                                     } else {
-                                        let tail_idx = Heap::pstr_tail_idx(pstr_loc);
+                                        let tail_idx = Heap::pstr_tail_idx(pstr_loc + c.len_utf8());
                                         unify_fn!(*self, self.heap[tail_idx], a3);
                                     }