]> Repositorios git - scryer-prolog.git/commitdiff
read Str focus properly in build_meta_predicate_clause
authorMark Thom <[email protected]>
Sat, 15 Mar 2025 09:10:04 +0000 (02:10 -0700)
committerMark Thom <[email protected]>
Wed, 23 Apr 2025 06:32:32 +0000 (23:32 -0700)
src/machine/preprocessor.rs

index 51e45a4a7d0c85a9d8850abf637ec33579bf6fc2..ff64494a33531315aed36d364a4c2f67ed2a1d48 100644 (file)
@@ -460,7 +460,19 @@ fn build_meta_predicate_clause<'a, LS: LoadState<'a>>(
     use crate::machine::heap::Heap;
     let mut index_ptrs = IndexMap::with_hasher(FxBuildHasher::default());
 
-    for (subterm_loc, meta_spec) in (term.focus + 1..term.focus + arity + 1).zip(meta_specs) {
+    let focus = {
+        let heap = loader.machine_heap();
+        let focus_cell =
+            heap_bound_store(heap, heap_bound_deref(heap, heap_loc_as_cell!(term.focus)));
+
+        if focus_cell.get_tag() == HeapCellValueTag::Str {
+            focus_cell.get_value() as usize
+        } else {
+            return index_ptrs;
+        }
+    };
+
+    for (subterm_loc, meta_spec) in (focus + 1..focus + arity + 1).zip(meta_specs) {
         if let MetaSpec::RequiresExpansionWithArgument(supp_args) = meta_spec {
             let predicate_key_opt = term_predicate_key(loader.machine_heap(), subterm_loc);