summaryrefslogtreecommitdiff
path: root/testsuite/tests/basic-more/pr10338.ml
blob: 2f63667b2a77e338c665353319f206ddbc2e7fd0 (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
(* TEST_BELOW*)

(* exercise push_defaults *)

let s = 42;;

let f ?(s="hello") = function x when (print_endline s; true) -> x;;

let () = f ();;

let f ?(y = assert false) (lazy e) = () in
  try f (lazy (print_endline "hello")) with _ -> print_endline "failed";;

type empty = |;;
let f : empty -> int = function _ -> .;;
let f ?y : empty -> int = function _ -> .;;
let f ?(y=1) : empty -> int = function _ -> .;;

module type E = sig exception Ex end;;
let f ((module M) : (module E)) (M.Ex | _) = "42";;
print_endline (f (module struct exception Ex end) Exit);;

(* push_defaults should push past the module pattern *)
let f ?(x = assert false) ((module M) : (module E)) () = 1;;
(* so partial application of the module doesn't raise *)
let partial = f (module struct exception Ex end);;

(* TEST
*)