fix indexing bug on anonvars.

This commit is contained in:
Mark Thom
2017-09-16 15:25:11 -06:00
parent e1644dcbb6
commit e4e9b09175
2 changed files with 11 additions and 8 deletions

View File

@@ -462,13 +462,16 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
let mut left_index = 0; let mut left_index = 0;
for (right_index, clause) in clauses.iter().enumerate() { for (right_index, clause) in clauses.iter().enumerate() {
if let Some(&Term::Var(_, _)) = clause.first_arg() { match clause.first_arg() {
if left_index < right_index { Some(&Term::Var(_, _)) | Some(&Term::AnonVar) => {
subseqs.push((left_index, right_index)); if left_index < right_index {
} subseqs.push((left_index, right_index));
}
subseqs.push((right_index, right_index + 1)); subseqs.push((right_index, right_index + 1));
left_index = right_index + 1; left_index = right_index + 1;
},
_ => {}
} }
} }

View File

@@ -254,8 +254,8 @@ pub fn eval<'a, 'b: 'a>(wam: &'a mut Machine, tl: &'b TopLevel) -> EvalSession<'
wam.submit_decl(decl), wam.submit_decl(decl),
&TopLevel::Predicate(ref clauses) => { &TopLevel::Predicate(ref clauses) => {
let mut cg = CodeGenerator::<DebrayAllocator>::new(); 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) wam.add_predicate(clauses, compiled_pred)
}, },
&TopLevel::Fact(ref fact) => { &TopLevel::Fact(ref fact) => {