summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-misc/pr7228.ml
blob: 480fa549afd841a8432ff5a5d175dd284cd5c849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(* TEST
 expect;
*)

type t = A of {mutable x: int};;
fun (A r) -> r.x <- 42;;
[%%expect{|
type t = A of { mutable x : int; }
- : t -> unit = <fun>
|}];;

(* Check that mutability is blocked for inline records on private types *)
type t = private A of {mutable x: int};;
fun (A r) -> r.x <- 42;;
[%%expect{|
type t = private A of { mutable x : int; }
Line 2, characters 15-16:
2 | fun (A r) -> r.x <- 42;;
                   ^
Error: Cannot assign field x of the private type t.A
|}];;