From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 85C1EBB81 for ; Fri, 9 Dec 2005 02:43:49 +0100 (CET) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jB91hlm3019844 for ; Fri, 9 Dec 2005 02:43:48 +0100 Received: from rosella (ppp33-4.lns1.syd2.internode.on.net [59.167.33.4] (may be forged)) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id jB91hVMU016876; Fri, 9 Dec 2005 12:13:33 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] partial application warning unreliable? From: skaller To: malc Cc: Jacques Garrigue , caml-list@yquem.inria.fr In-Reply-To: References: <1134009551.10435.24.camel@rosella> <20051208.121012.49167263.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Fri, 09 Dec 2005 12:43:31 +1100 Message-Id: <1134092611.8940.57.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4398E153.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 malc:01 semicolon:01 endline:01 ocaml:01 -warn-error:01 bug:01 endline:01 val:01 uncaught:01 arity:01 wrote:01 wrote:01 sourceforge:01 partial:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Fri, 2005-12-09 at 02:51 +0300, malc wrote: > On Thu, 8 Dec 2005, Jacques Garrigue wrote: > > > > > > # class cc = object (self) > > method f x y = x + y > > method g () = self#f 1; > > end;; > > class cc : > > object method f : int -> int -> int method g : unit -> int -> int end > > > > No warning, for the reason stated above: the semicolon does nothing. > > Here's a strange test case, i was bitten by it recently in a real code: > > > let y o = > o#moo; > 1 > > let x (o:( unit>)) = > y o > > let _ = > print_int (x (object method moo s = print_endline s end)); > print_newline () > > > # ocaml -warn-error A mox.ml > 1 > > In my case method moo was actually a method that locked a mutex, the > implications were quite severe. AHA. In trying to fill out your problem to a real test case for a bug report .. I think I have discovered the problem! # class cow = object(self) method moo (s:string)= print_endline s end;; class cow : object method moo : string -> unit end # let y o = o#moo; 1;; val y : < moo : 'a; .. > -> int = And there we have it .. an uncaught partial application! The reason is clear .. we don't know the arity of the function yet -- we don't even know its type. The type of a statement is currently 'a, which is just plain wrong. The correct type is void, however unit will catch more errors than 'a. -- John Skaller Felix, successor to C++: http://felix.sf.net