summaryrefslogtreecommitdiff
path: root/testsuite/tests/callback/stack_overflow.ml
blob: 9b48df20e990fd0207feb7d03fbfe26d8f08db8c (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
(* TEST
 include unix;
 modules = "stack_overflow_.c";
 libunix;
 {
   bytecode;
 }{
   native;
 }
*)

external caml_to_c : (unit -> 'a) -> 'a = "caml_to_c"

let rec deep = function
  | 0 ->
     ref 42
  | n ->
     caml_to_c (fun () -> deep (n-1))

open Effect
open Effect.Deep

type _ t += E : unit t

let () =
  Printf.printf "%d\n%d\n%!"
    (!(deep 1000))
    (match_with deep 1000
     { retc = (fun x -> !x);
       exnc = (fun e -> raise e);
       effc = fun (type a) (e : a t) ->
         match e with
         | E -> Some (fun k -> assert false)
         | _ -> None })