summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-private/invalid_private_row.ml
blob: 18ec0fc71d6d2f88e4860f53df102d6a458e0c45 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(* TEST
 expect;
*)

(** Error message for trying to make private a row type variable
    that only exists syntactically *)

type a = [`A | `C | `D]
type b = [`B | `D | `E]
type c = private [< a | b > `A `B `C `D `E]
[%%expect {|
type a = [ `A | `C | `D ]
type b = [ `B | `D | `E ]
Line 6, characters 0-43:
6 | type c = private [< a | b > `A `B `C `D `E]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This private row type declaration is invalid.
       The type expression on the right-hand side reduces to
         [ `A | `B | `C | `D | `E ]
       which does not have a free row type variable.
       Hint: If you intended to define a private type abbreviation,
       write explicitly
         private [ `A | `B | `C | `D | `E ]
|}]

type u = private < x:int; .. > as 'a constraint 'a = < x: int > ;;
[%%expect {|
Line 1, characters 0-63:
1 | type u = private < x:int; .. > as 'a constraint 'a = < x: int > ;;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This private row type declaration is invalid.
       The type expression on the right-hand side reduces to
         < x : int >
       which does not have a free row type variable.
       Hint: If you intended to define a private type abbreviation,
       write explicitly
         private < x : int >
|}]

type u = private [> `A ] as 'a constraint 'a = [< `A ] ;;
[%%expect {|
Line 1, characters 0-54:
1 | type u = private [> `A ] as 'a constraint 'a = [< `A ] ;;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This private row type declaration is invalid.
       The type expression on the right-hand side reduces to
         [ `A ]
       which does not have a free row type variable.
       Hint: If you intended to define a private type abbreviation,
       write explicitly
         private [ `A ]
|}]