blob: c76a070a1407b7c238271abdaa308365599b4884 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
(* TEST_BELOW
(* Blank lines added here to preserve locations. *)
*)
open Effect
open Effect.Deep
let rec foo i =
if i = 0 then ()
else begin
ignore (failwith "exn");
foo i
end
[@@inline never]
let rec bar i =
if i = 0 then ()
else begin
foo i;
bar i
end
[@@inline never]
type _ t += Wait : unit t
let task1 () =
try
bar 42; None
with e ->
Some (e, Printexc.get_raw_backtrace ())
let rec task2 i =
if i = 0 then ()
else begin
perform Wait;
task2 i
end
[@@inline never]
let main () =
let (x, bt) = Option.get (task1 ()) in
match_with task2 42
{ retc = Fun.id;
exnc = (fun e ->
let open Printexc in
print_raw_backtrace stdout (get_raw_backtrace ()));
effc = fun (type a) (e : a t) ->
match e with
| Wait -> Some (fun (k : (a, _) continuation) ->
discontinue_with_backtrace k x bt)
| _ -> None }
let _ = main ()
(* TEST
flags = "-g";
ocamlrunparam += ",b=1";
*)
|