Anonymous avatar Anonymous committed 858a6df

Fixed bug with exception port

Comments (0)

Files changed (1)

prolog/interpreter/continuation.py

     @jit.unroll_safe
     def throw(self, exc, scont, fcont, heap):
         # XXX write tests for catching non-ground things
+        # Trace: exception will print backtrace and overwrite scont, fcont heap
+        orig_scont = scont
+        orig_fcont = fcont
+        orig_heap = heap
         while not scont.is_done():
             if isinstance(scont, TraceSuccessContinuation):
                 scont = scont.trace_exception()
-                scont, fcont, heap = scont.activate(fcont, heap)
-                continue
+                if not isinstance(scont, DoneSuccessContinuation):
+                    scont, fcont, heap = scont.activate(fcont, heap)
+                    continue
+                else:
+                    # now, throw the exception on the raising continuations
+                    scont, fcont, heap = orig_scont.trace_unwrap(), orig_fcont.trace_unwrap(), orig_heap
+                    continue
             if not isinstance(scont, CatchingDelimiter):
                 scont = scont.nextcont
                 continue
         return self
 
     def trace_unwrap(self):
-        if self.port != "Exit":
+        if self.port == "Call" or self.port is None:
             cont = self.innercont
             cont.nextcont = cont.nextcont.trace_unwrap()
-        else:
+        else: # Exit or Exception
             cont = self.nextcont.trace_unwrap()
         return cont
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.