add test for polymorphic variants

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11296 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jacques Garrigue 2011-12-10 02:47:40 +00:00
parent 5b0de6f31c
commit 8074552780
3 changed files with 19 additions and 0 deletions

View File

@ -454,3 +454,16 @@ let f : type a b. (a M.t * a, b M.t * b) eq -> (a, b) eq =
let f : type a b. (a * a M.t, b * b M.t) eq -> (a, b) eq =
function Eq -> Eq (* ok *)
;;
(* Applications of polymorphic variants *)
type _ t =
| V1 : [`A | `B] t
| V2 : [`C | `D] t
let f : type a. a t -> a = function
| V1 -> `A
| V2 -> `C
;;
f V1;;

View File

@ -276,4 +276,7 @@ Error: This expression has type (a, a) eq
but an expression was expected of type (a, b) eq
# val f : ('a M.t * 'a, 'b M.t * 'b) eq -> ('a, 'b) eq = <fun>
# val f : ('a * 'a M.t, 'b * 'b M.t) eq -> ('a, 'b) eq = <fun>
# type 'a t = V1 : [ `A | `B ] t | V2 : [ `C | `D ] t
val f : 'a t -> 'a = <fun>
# - : [ `A | `B ] = `A
#

View File

@ -263,4 +263,7 @@ Error: This expression has type (a, a) eq
but an expression was expected of type (a, b) eq
# val f : ('a M.t * 'a, 'b M.t * 'b) eq -> ('a, 'b) eq = <fun>
# val f : ('a * 'a M.t, 'b * 'b M.t) eq -> ('a, 'b) eq = <fun>
# type 'a t = V1 : [ `A | `B ] t | V2 : [ `C | `D ] t
val f : 'a t -> 'a = <fun>
# - : [ `A | `B ] = `A
#