mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-05-01 01:04:43 +00:00
Estimated hours taken: 1
Branches: main
Specify the behaviour of finalisers and mutable initial value expressions
w.r.t to exceptions.
doc/reference_manual.texi:
Specify what happens if a finaliser terminates with an uncaught
exception.
Specify the order of initialisation for mutables w.r.t initialise
declarations.
Specify what happens if a mutable initial value expression
terminates with an uncaught exception.
tests/hard_coded/Mmakefile:
Add the new test cases.
tests/hard_coded/final_excp.{m,exp}:
Test the behaviour of finalisers that throw exceptions.
test/hard_coded/mutable_init_order.{m,exp}:
Test that mutables are initialised in the correct order relative
to initialise declarations.
tests/hard_coded/mutabel_excp.{m,exp}:
Test the behaviour of mutable initial value expressions that
throw exceptions.
25 lines
495 B
Mathematica
25 lines
495 B
Mathematica
% Test that mutable initialisation occurs in the correct order
|
|
% relative to initialise declarations.
|
|
%
|
|
:- module mutable_init_order.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- mutable(global, int, 561, ground, [untrailed, attach_to_io_state]).
|
|
:- initialise foo/2.
|
|
|
|
:- pred foo(io::di, io::uo) is det.
|
|
|
|
foo(!IO) :-
|
|
set_global(908, !IO).
|
|
|
|
main(!IO) :-
|
|
get_global(V, !IO),
|
|
io.write_string("V = ", !IO),
|
|
io.write_int(V, !IO),
|
|
io.nl(!IO).
|