blob: e8b28342b8622416f9659026304a075b1134a854 (
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
|
(* TEST
* expect
*)
let f ~x () = x ();;
[%%expect{|
val f : x:(unit -> 'a) -> unit -> 'a = <fun>
|}];;
let rec x = f ~x;;
[%%expect{|
Line 1, characters 12-16:
1 | let rec x = f ~x;;
^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
|}];;
let f x ~y = x + y
(* this function creates "abstracted arguments" in the sense of
Rec_check.is_abstracted_arg. Those should be treated as
returned/unguarded, and not delayed, otherwise the code below
segfaults. *)
let rec g = f ~y:(print_endline !y; 0)
and y =
let _ = g in (* ignore g to have a real dependency *)
ref "foo";;
[%%expect {|
val f : int -> y:int -> int = <fun>
Line 6, characters 12-38:
6 | let rec g = f ~y:(print_endline !y; 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'
|}]
|