SWI-Prolog / issues

Dummy repository for issue tracking
8 stars 3 forks source link

Unexpected uncaught error #129

Closed notoria closed 1 year ago

notoria commented 1 year ago
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- catch(catch(throw(a), E0, throw(b)), E, true).
E = b.

?- catch(catch(throw(a), E, throw(b)), E, true).
ERROR: Unhandled exception: Unknown message: b
?-

Expected the same result as the first query.

JanWielemaker commented 1 year ago

It is a deliberate deviation from the standard. SWI-Prolog searches for a matching catch/3 before unwinding the exception and backtracking. The advantage of that is that we have all context around when deciding the exception is uncaught and therefore can trap the debugger will all relevant information for debugging still around.