Source

compiler-libs-hack / ocaml / testsuite / tests / typing-gadts / pr5948.ml.reference

Full commit

# type tag = [ `TagA | `TagB | `TagC ]
#           type 'a poly =
    AandBTags : [< `TagA of int | `TagB ] poly
  | ATag : [< `TagA of int ] poly
#       val intA : [< `TagA of 'a ] -> 'a = <fun>
val intB : [< `TagB ] -> int = <fun>
#         val intAorB : [< `TagA of int | `TagB ] -> int = <fun>
#       type _ wrapPoly =
    WrapPoly : 'a poly -> ([< `TagA of int | `TagB ] as 'a) wrapPoly
#             Characters 103-107:
      | WrapPoly ATag -> intA
                         ^^^^
Error: This expression has type ([< `TagA of 'b ] as 'a) -> 'b
       but an expression was expected of type a -> int
       Type 'a is not compatible with type a = [< `TagA of int | `TagB ] 
       The first variant type does not allow tag(s) `TagB
#     Characters 10-18:
  let _ =  example6 (WrapPoly AandBTags) `TagB (* This causes a seg fault *)
           ^^^^^^^^
Error: Unbound value example6
#