English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] [Q] explicit typing again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-03-29 (13:07)
From: skaller <skaller@u...>
Subject: [Caml-list] Polymorphic Variant Error message (CVS version)
# type t = [`A of t]
  let rec f (x:t) = match x with
  | `A y -> f y
  | `B y -> f y

Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Warning: this match case is unused.
type t = [ `A of t ]
val f : t -> 'a = <fun>
The first error message is a bit confusing.
There is indeed an extra tag `B in the match.

I think this kind of message only occurs where there
is a covariant type.

The confusion is: it says the pattern matching
is not exhaustive, but from the developers viewpoint
the opposite is true: the match is overconstrained,
rather than underconstrained. I guess the problem arises
becase the type of x is deduced from the match first,
before the annotation restricts it to type t.

Anyhow just curious exactly how this error arises.

John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners