]> Repositorios git - scryer-prolog.git/commitdiff
fix indexing bug on anonvars.
authorMark Thom <[email protected]>
Sat, 16 Sep 2017 21:25:11 +0000 (15:25 -0600)
committerMark Thom <[email protected]>
Sat, 16 Sep 2017 21:25:11 +0000 (15:25 -0600)
src/prolog/codegen.rs
src/prolog/io.rs

index 503771400829a2f67f21b8aa2767936a4a6317aa..d67c32e02decd0ba2b1744cbc6935a18771454ee 100644 (file)
@@ -462,13 +462,16 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
         let mut left_index = 0;
 
         for (right_index, clause) in clauses.iter().enumerate() {
-            if let Some(&Term::Var(_, _)) = clause.first_arg() {
-                if left_index < right_index {
-                    subseqs.push((left_index, right_index));
-                }
+            match clause.first_arg() {
+                Some(&Term::Var(_, _)) | Some(&Term::AnonVar) => {
+                    if left_index < right_index {
+                        subseqs.push((left_index, right_index));
+                    }
 
-                subseqs.push((right_index, right_index + 1));
-                left_index = right_index + 1;
+                    subseqs.push((right_index, right_index + 1));
+                    left_index = right_index + 1;
+                },
+                _ => {}
             }
         }
 
index cb005a04a20b2852fc704bbe345273bcf071722a..6610c233391193cc05d93e0a956388dd549b6c71 100644 (file)
@@ -254,8 +254,8 @@ pub fn eval<'a, 'b: 'a>(wam: &'a mut Machine, tl: &'b TopLevel) -> EvalSession<'
             wam.submit_decl(decl),
         &TopLevel::Predicate(ref clauses) => {
             let mut cg = CodeGenerator::<DebrayAllocator>::new();
-            let compiled_pred = cg.compile_predicate(clauses);
-            
+
+            let compiled_pred = cg.compile_predicate(clauses);            
             wam.add_predicate(clauses, compiled_pred)
         },
         &TopLevel::Fact(ref fact) => {