mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 19:33:46 +00:00
This fixes a serious issue as `try' goals are not properly written to .opt files, so when read back would not actually catch any exceptions. Bug #420. At the point where we are to create the .opt file, the pieces of a `try' goal exist in a "pre-transformed" hlds_goal. Teasing apart the pieces to resemble the original `try' goal would be non-trivial. compiler/intermod.m: Do not export any predicate or function with a clause containing a `try' goal. library/exception.m Throw an exception if the dummy predicate `magic_exception_result/1' is ever called. tests/hard_coded/Mercury.options: tests/hard_coded/Mmakefile: tests/hard_coded/intermod_try_goal.exp: tests/hard_coded/intermod_try_goal.m: tests/hard_coded/intermod_try_goal2.m: Add test case. NEWS: Announce change.
31 lines
737 B
Mathematica
31 lines
737 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module intermod_try_goal2.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred catcher(pred(io, io), io, io).
|
|
:- mode catcher(pred(di, uo) is det, di, uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module string.
|
|
|
|
% intermod.m must ignore this pragma until `try' goals can be written
|
|
% properly to .opt files.
|
|
%
|
|
:- pragma inline(catcher/3).
|
|
|
|
catcher(Pred, !IO) :-
|
|
( try [io(!IO)]
|
|
Pred(!IO)
|
|
then
|
|
true
|
|
catch_any Excp ->
|
|
io.write_string("caught exception: " ++ string(Excp), !IO),
|
|
io.nl(!IO)
|
|
).
|