Commits

Carl Friedrich Bolz committed f18f2cc

test and fix about the interoperation of exceptions and findall

  • Participants
  • Parent commits bba9d48

Comments (0)

Files changed (2)

File prolog/builtin/allsolution.py

 # finding all solutions to a goal
 
 class FindallContinuation(continuation.Continuation):
-    def __init__(self, engine, template, heap):
-        continuation.Continuation.__init__(self, engine, None)
+    def __init__(self, engine, template, heap, scont):
+        # nextcont still needs to be set, for correct exception propagation
+        continuation.Continuation.__init__(self, engine, scont)
         self.resultvar = self.fullsolution = heap.newvar()
         self.template = template
         self.heap = heap
                 handles_continuation=True, needs_module=True)
 def impl_findall(engine, heap, module, template, goal, bag, scont, fcont):
     newheap = heap.branch()
-    collector = FindallContinuation(engine, template, heap)
+    collector = FindallContinuation(engine, template, heap, scont)
     newscont = continuation.BodyContinuation(engine, module, collector, goal)
     fcont = DoneWithFindallContinuation(engine, scont, fcont, heap, collector, bag)
     return newscont, fcont, newheap

File prolog/interpreter/test/test_builtin.py

     """)
     assert_true("findall(X+Y, app(X, Y, [1, 2, 3]), L), L == [[]+[1, 2, 3], [1]+[2, 3], [1, 2]+[3], [1, 2, 3]+[]].", e)
 
+def test_findall_and_exception_bug():
+    prolog_raises("instantiation_error", "findall(1, 0 is X, _)")
+
 
 def test_ifthenelse():
     assert_false("true -> fail.")