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 LAA25492; Sat, 7 Sep 2002 11:30:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA25565 for ; Sat, 7 Sep 2002 11:30:25 +0200 (MET DST) Received: from favie.faith.gr.jp (favie.faith.gr.jp [61.127.175.250]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g879UN129620 for ; Sat, 7 Sep 2002 11:30:23 +0200 (MET DST) Received: from localhost (dhcp7.faith.gr.jp [192.168.1.17]) by favie.faith.gr.jp (8.9.3/8.9.3) with ESMTP id SAA24344; Sat, 7 Sep 2002 18:30:16 +0900 To: dimitri@nerim.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] strange typing errors In-Reply-To: <874rd3wy5z.fsf@corwin.mutu.net> References: <874rd3wy5z.fsf@corwin.mutu.net> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020907182958F.garrigue@kurims.kyoto-u.ac.jp> Date: Sat, 07 Sep 2002 18:29:58 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Dimitri Ara > While ICFPing, I came upon some strange typing error messages. > > The first one is : > > class type ct = object > method m : l:int -> ct > end > > let rec f (o : ct) = > let rec g o = > let x = o#m 1 in > g x in > g o > > This expression has type ct = < m : l:int -> ct > as 'a > but is here used with type 'a Indeed not very instructive. Ah, backtracking on unification... Could you file a bug? I will try to fix it. By the way, the real problem in the above code is that the type annotation is not in a useful place. It should be where you are going to call methods: let rec f o = let rec g (o : ct) = let x = o#m 1 in g x in g o > The second one is ill-typed and get the same error message: > > class type ct = object > method m : l:int -> int > end > > let rec f (o : ct) = > let rec g o = > let x = o#m 1 in > g x in > g o Sure: the problem is with the label, same cause, same effect. > If I remove the label I got a stranger error: > > This expression has type ct = < m : int -> int > as 'a > but is here used with type 'a > Type int is not compatible with type ct = 'a Same kind of unification problem. Fortunately, the second line is more helpful: an int was unified wis a ct. With right annotation you get: # let rec f o = let rec g (o : ct) = let x = o#m 1 in g x in ^ g o;; This expression has type int but is here used with type ct = < m : l:int -> int > Cheers, Jacques Garrigue ------------------- 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