33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
|
|
# type ab = [ `A | `B ]
|
|
# Characters 32-35:
|
|
let f (x : [`A]) = match x with #ab -> 1;;
|
|
^^^
|
|
Error: This pattern matches values of type [? `A | `B ]
|
|
but a pattern was expected which matches values of type [ `A ]
|
|
The second variant type does not allow tag(s) `B
|
|
# Characters 31-34:
|
|
let f x = ignore (match x with #ab -> 1); ignore (x : [`A]);;
|
|
^^^
|
|
Error: This pattern matches values of type [? `B ]
|
|
but a pattern was expected which matches values of type [ `A ]
|
|
Types for tag `B are incompatible
|
|
# Characters 34-36:
|
|
let f x = ignore (match x with `A|`B -> 1); ignore (x : [`A]);;
|
|
^^
|
|
Error: This pattern matches values of type [? `B ]
|
|
but a pattern was expected which matches values of type [ `A ]
|
|
Types for tag `B are incompatible
|
|
# Characters 50-52:
|
|
let f (x : [< `A | `B]) = match x with `A | `B | `C -> 0;; (* warn *)
|
|
^^
|
|
Warning 12: this sub-pattern is unused.
|
|
val f : [< `A | `B ] -> int = <fun>
|
|
# Characters 47-49:
|
|
let f (x : [`A | `B]) = match x with `A | `B | `C -> 0;; (* fail *)
|
|
^^
|
|
Error: This pattern matches values of type [? `C ]
|
|
but a pattern was expected which matches values of type [ `A | `B ]
|
|
The second variant type does not allow tag(s) `C
|
|
#
|