SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

Unexpected uncaught error #129

Closed notoria closed 9 months ago

notoria commented 9 months 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 9 months 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.