set compound to succeed on non-empty lists.

This commit is contained in:
Mark Thom
2018-02-16 22:34:27 -07:00
parent 61bc5a2a29
commit 8b566ab4e5
3 changed files with 7 additions and 7 deletions

View File

@@ -368,7 +368,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
}, },
&InlinedQueryTerm::IsCompound(ref inner_term) => &InlinedQueryTerm::IsCompound(ref inner_term) =>
match inner_term[0].as_ref() { match inner_term[0].as_ref() {
&Term::Clause(..) => { &Term::Clause(..) | &Term::Cons(..) => {
code.push(succeed!()); code.push(succeed!());
}, },
&Term::Var(ref vr, ref name) => { &Term::Var(ref vr, ref name) => {

View File

@@ -1371,7 +1371,7 @@ SetupCallCleanupCutPolicy.")
let d = self.store(self.deref(self[r].clone())); let d = self.store(self.deref(self[r].clone()));
match d { match d {
Addr::Str(_) => self.p += 1, Addr::Str(_) | Addr::Lis(_) => self.p += 1,
_ => self.fail = true _ => self.fail = true
}; };
}, },

View File

@@ -1311,12 +1311,12 @@ fn test_queries_on_builtins()
assert_prolog_success!(&mut wam, "?- compound(functor(compound))."); assert_prolog_success!(&mut wam, "?- compound(functor(compound)).");
assert_prolog_success!(&mut wam, "?- compound(f(X))."); assert_prolog_success!(&mut wam, "?- compound(f(X)).");
assert_prolog_success!(&mut wam, "?- compound([1,2,3]).");
assert_prolog_failure!(&mut wam, "?- compound([]).");
assert_prolog_failure!(&mut wam, "?- compound(3.14159269)."); assert_prolog_failure!(&mut wam, "?- compound(3.14159269).");
assert_prolog_failure!(&mut wam, "?- compound(3)."); assert_prolog_failure!(&mut wam, "?- compound(3).");
assert_prolog_failure!(&mut wam, "?- compound(\"sdfsa\")."); assert_prolog_failure!(&mut wam, "?- compound(\"sdfsa\").");
assert_prolog_failure!(&mut wam, "?- compound(atom)."); assert_prolog_failure!(&mut wam, "?- compound(atom).");
assert_prolog_failure!(&mut wam, "?- compound([1,2,3]).");
assert_prolog_failure!(&mut wam, "?- compound([1,2,X]).");
assert_prolog_failure!(&mut wam, "?- string(functor(string))."); assert_prolog_failure!(&mut wam, "?- string(functor(string)).");
assert_prolog_failure!(&mut wam, "?- string(3.14159269)."); assert_prolog_failure!(&mut wam, "?- string(3.14159269).");