From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA19772; Mon, 29 Mar 2004 15:07:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA19214 for ; Mon, 29 Mar 2004 15:07:43 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2TD8MKW012358 for ; Mon, 29 Mar 2004 15:08:24 +0200 Received: from [192.168.1.200] (ppp113-158.lns1.syd3.internode.on.net [150.101.113.158]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i2TD7cUK032377 for ; Mon, 29 Mar 2004 22:37:39 +0930 (CST) Subject: [Caml-list] Polymorphic Variant Error message (CVS version) From: skaller Reply-To: skaller@users.sourceforge.net To: caml-list In-Reply-To: References: Content-Type: text/plain Message-Id: <1080565657.4708.241.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Mar 2004 23:07:37 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; sourceforge:01 val:01 covariant:01 9660:01 glebe:01 anyhow:01 rec:01 nsw:01 polymorphic:01 snail:02 variant:02 match:02 match:02 checkout:02 2037:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 411 Consider: -------------------------------------- # 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: `AnyExtraTag Warning: this match case is unused. type t = [ `A of t ] val f : t -> 'a = ------------------------------------------ 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