summaryrefslogtreecommitdiff
path: root/testsuite/tests/tmc/tupled_function_calls.ml
blob: 1ce7fa5f6ef43706daa5a0e38ae53e7a0a3e9ce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(* TEST
   * bytecode
   * native
*)

(* this works as expected *)
let[@tail_mod_cons] rec tupled_map (f, li) =
  match li with
  | [] -> []
  | x :: xs -> f x :: tupled_map (f, xs)

(* The recursive call here is not "direct" for the
   Tupled calling convention (which is only used by the native compiler),
   so it will not be eligible for TMC optimization.
   We expect a warning here, when compiling with the native compiler. *)
let[@tail_mod_cons] rec tupled_map_not_direct (f, li) =
  match li with
  | [] -> []
  | x :: xs ->
      let pair = (f, xs) in
      f x :: (tupled_map_not_direct[@tailcall true]) pair