do not traverse data structures when binding to local variables in unify_with_occurs_check
@@ -201,6 +201,14 @@ fn bind(&mut self, r1: Ref, a2: Addr) {
}
fn bind_with_occurs_check(&mut self, r: Ref, addr: Addr) {
+ if let Ref::StackCell(..) = r {
+ // local variable optimization -- r cannot occur in the
+ // data structure bound to addr, so don't bother
+ // traversing it.
+ self.bind(r, addr);
+ return;
+ }
+
let mut fail = false;
for addr in self.acyclic_pre_order_iter(addr) {
