Avoid infinite recursion: replace the variables without calling the method recursively
This commit is contained in:
parent
928f0cb273
commit
4e1abad452
|
|
@ -82,15 +82,15 @@ public class Unification {
|
|||
private void union(Node s, Node t) {
|
||||
Integer ssize = getSize(s);
|
||||
Integer tsize = getSize(t);
|
||||
|
||||
// keep the order
|
||||
if (ssize < tsize) {
|
||||
union(t, s);
|
||||
return;
|
||||
Node tmp = t; t = s; s = tmp;
|
||||
}
|
||||
if (ssize == tsize && s.isVar() && t.isVar()) {
|
||||
else if (ssize == tsize && s.isVar() && t.isVar()) {
|
||||
// ensure proper order of variables in the substitution
|
||||
if(s.asVar().compareTo(t.asVar()) < 0) {
|
||||
union(t, s);
|
||||
return;
|
||||
Node tmp = t; t = s; s = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue