| 1 |
(* This toplevel test exercises some polymorphic variants that sexp_grammar rejects. We |
| 2 |
show that in each case, the compiler or sexp would have given an error anyway. *) |
| 3 |
|
| 4 |
open Base |
| 5 |
|
| 6 |
type t = [ `A of int & string ] [@@deriving sexp] |
| 7 |
|
| 8 |
[%%expect |
| 9 |
{| |
| 10 |
Line _, characters _-_: |
| 11 |
Error: unsupported: polymorphic variant intersection type |
| 12 |
|}] |
| 13 |
|
| 14 |
type t = [ `A of int & string ] [@@deriving sexp_grammar] |
| 15 |
|
| 16 |
[%%expect |
| 17 |
{| |
| 18 |
Line _, characters _-_: |
| 19 |
Error: sexp_grammar: intersection types are unsupported |
| 20 |
|}] |
| 21 |
|
| 22 |
type t = [> `A ] [@@deriving sexp] |
| 23 |
|
| 24 |
[%%expect |
| 25 |
{| |
| 26 |
Line _, characters _-_: |
| 27 |
Error: Type unsupported for ppx [of_sexp] conversion |
| 28 |
|}] |
| 29 |
|
| 30 |
type t = [> `A ] [@@deriving sexp_grammar] |
| 31 |
|
| 32 |
[%%expect |
| 33 |
{| |
| 34 |
Line _, characters _-_: |
| 35 |
Error: sexp_grammar: open polymorphic variant types are unsupported |
| 36 |
|}] |
| 37 |
|
| 38 |
type t = [< `A ] [@@deriving sexp] |
| 39 |
|
| 40 |
[%%expect |
| 41 |
{| |
| 42 |
Line _, characters _-_: |
| 43 |
Error: A type variable is unbound in this type declaration. |
| 44 |
In type [< `A ] as 'a the variable 'a is unbound |
| 45 |
|}] |
| 46 |
|
| 47 |
type t = [< `A ] [@@deriving sexp_grammar] |
| 48 |
|
| 49 |
[%%expect |
| 50 |
{| |
| 51 |
Line _, characters _-_: |
| 52 |
Error: A type variable is unbound in this type declaration. |
| 53 |
In type [< `A ] as 'a the variable 'a is unbound |
| 54 |
|}] |
| 55 |
|
| 56 |
type 'a t = [< `A ] as 'a [@@deriving sexp] |
| 57 |
|
| 58 |
[%%expect |
| 59 |
{| |
| 60 |
Line _, characters _-_: |
| 61 |
Error: Type unsupported for ppx [of_sexp] conversion |
| 62 |
|}] |
| 63 |
|
| 64 |
type 'a t = [< `A ] as 'a [@@deriving sexp_grammar] |
| 65 |
|
| 66 |
[%%expect |
| 67 |
{| |
| 68 |
Line _, characters _-_: |
| 69 |
Error: sexp_grammar: type aliases are unsupported |
| 70 |
|}] |
| 71 |
|
| 72 |
type a = A : [> ] -> a [@@deriving sexp] |
| 73 |
|
| 74 |
[%%expect |
| 75 |
{| |
| 76 |
Line _, characters _-_: |
| 77 |
Error: Type unsupported for ppx [of_sexp] conversion |
| 78 |
|}] |
| 79 |
|
| 80 |
type a = A : [> ] -> a [@@deriving sexp_of] |
| 81 |
|
| 82 |
[%%expect |
| 83 |
{| |
| 84 |
Line _, characters _-_: |
| 85 |
Error: Type unsupported for ppx [sexp_of] conversion |
| 86 |
|}] |
| 87 |
|
| 88 |
type a = [ `A ] [@@deriving sexp];; |
| 89 |
|
| 90 |
#verbose true |
| 91 |
|
| 92 |
let f = [%sexp_of: [< a ]] |
| 93 |
|
| 94 |
[%%expect |
| 95 |
{| |
| 96 |
val f : [< a ] -> Sexp.t = <fun> |
| 97 |
|}] |
| 98 |
|
| 99 |
let f = [%of_sexp: [> a ]] |
| 100 |
|
| 101 |
[%%expect |
| 102 |
{| |
| 103 |
Line _, characters _-_: |
| 104 |
Error: Type unsupported for ppx [of_sexp] conversion |
| 105 |
|}] |
| 106 |
|
| 107 |
let f = [%of_sexp: [ | a ]] |
| 108 |
|
| 109 |
[%%expect |
| 110 |
{| |
| 111 |
val f : Sexp.t -> a = <fun> |
| 112 |
|}] |
| 113 |
;; |
| 114 |
|
| 115 |
#verbose false |