do not unify partial strings unless they coincide in memory

This commit is contained in:
Mark Thom
2018-09-03 00:20:01 -06:00
parent c5fd13dfa0
commit 3960ea4f06
2 changed files with 11 additions and 8 deletions

View File

@@ -264,11 +264,11 @@ impl MachineState {
if let Some(c) = s2.head() { if let Some(c) = s2.head() {
pdl.push(Addr::Con(Constant::String(s1.push_char(c)))); pdl.push(Addr::Con(Constant::String(s1.push_char(c))));
pdl.push(Addr::Con(Constant::String(s2.tail()))); pdl.push(Addr::Con(Constant::String(s2.tail())));
} else if !s2.is_expandable() { } else if s2.is_expandable() {
return s1 == s2;
} else {
s1.set_non_expandable(); s1.set_non_expandable();
}/*else { }
//TODO: unify the tails of s1 and s2? I guess?
}*/
return true; return true;
} else if s2.head().is_none() { } else if s2.head().is_none() {

View File

@@ -1881,6 +1881,9 @@ fn test_queries_on_string_lists()
assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X).", assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X).",
[["X = [a, b, c | _]"]]); [["X = [a, b, c | _]"]]);
assert_prolog_failure!(&mut wam, "?- partial_string(\"abc\", X), partial_string(\"abc\", Y), matcher(X, V),
matcher(Y, Z), V = Z.");
submit(&mut wam, "matcher([a, b, c | X], X)."); submit(&mut wam, "matcher([a, b, c | X], X).");
assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X), matcher(X, Y).", assert_prolog_success!(&mut wam, "?- partial_string(\"abc\", X), matcher(X, Y).",