1. Carl Friedrich Bolz
  2. Pyrolog

Commits

Carl Friedrich Bolz  committed 81b5fca

gah, most annoying bug ever: revert attvars in reverse order (obviously)

  • Participants
  • Parent commits d765c5c
  • Branches default

Comments (0)

Files changed (2)

File prolog/interpreter/heap.py

View file
         self.i = 0
 
         if self.trail_attrs is not None:
-            for attvar, index, value in self.trail_attrs:
+            for i in range(len(self.trail_attrs) - 1, -1, -1):
+                attvar, index, value = self.trail_attrs[i]
                 attvar.reset_field(index, value)
 
         self.trail_attrs = None

File prolog/interpreter/test/test_attvars.py

View file
     assert_false("put_attr(X, m, 2), (put_attr(X, m, 1), fail); get_attr(X, m, 2).")
     assert_true("(put_attr(X, b, 1), fail); \+ get_attr(X, b, 1).")
     assert_true("put_attr(X, a, 2), ((put_attr(X, b, 1), fail); get_attr(X, a, 2)), \+ get_attr(X, b, 1).")
+    assert_true("put_attr(X, a, 2), ((put_attr(X, a, 1), put_attr(X, a, 3), fail); get_attr(X, a, 2)).")
     assert_true("put_attr(X, a, 2), ((put_attr(X, b, 1), put_attr(X, c, 3), fail); get_attr(X, a, 2)), \+ get_attr(X, b, 1), \+ get_attr(X, c, 3).")
 
 def test_del_attributes():