From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA03132 for caml-redistribution; Fri, 30 Jul 1999 03:20:54 +0200 (MET DST) 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 RAA16099 for ; Tue, 27 Jul 1999 17:34:46 +0200 (MET DST) Received: from tcs.inf.tu-dresden.de (tcs.inf.tu-dresden.de [141.76.75.119]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id RAA00146 for ; Tue, 27 Jul 1999 17:34:45 +0200 (MET DST) Received: from ithif20.inf.tu-dresden.de (ithif20 [141.76.75.120]) by tcs.inf.tu-dresden.de (8.9.1a/8.9.1) with SMTP id RAA29253 for ; Tue, 27 Jul 1999 17:34:22 +0200 (MET DST) Received: by ithif20.inf.tu-dresden.de (SMI-8.6/SMI-SVR4) id RAA15742; Tue, 27 Jul 1999 17:34:51 +0200 Date: Tue, 27 Jul 1999 17:34:51 +0200 Message-Id: <199907271534.RAA15742@ithif20.inf.tu-dresden.de> From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: caml-list@inria.fr Subject: Re: Diagnostic bug? In-Reply-To: <3.0.6.32.19990722165137.00976500@mail.triode.net.au> References: <199907181757.TAA31587@miss.wu-wien.ac.at> <3.0.6.32.19990722165137.00976500@mail.triode.net.au> X-Mailer: VM 6.34 under Emacs 19.34.1 Sender: weis Hi, as an answer to John I am just telling my heuristics to track down type errors: Assuming, that John started with the following program: type t = T;; let rec g (x) = let (aT : t) = f x in () and f x = ();; then, he gets the error File "t.ml", line 5, characters 10-12: This expression has type unit but is here used with type t Now this indicates, that there is something wrong with at least one of ``f'', ``x'', or ``()''. The error occurs, because from previous uses of the problematic identifiers the compiler collected type information, which in incompatible with line 5. Therefore my strategy is to add type annotations at the first use of the problematic identifiers, which leads to type t = T;; let rec g (x) = let (aT : t) = (f : 'a -> unit) x in () and f x = ();; or alternatively type t = T;; let rec g (x) = let (aT : t) = (f x : unit) in () and f x = ();; For both programs the compiler generates a usable error message. John Skaller writes: In my actual code, I got an error in a 5000 character expression, and it took three days to figure out the error wasn't in that expression at all. You are right, error reporting is one of the weak points of the ocaml system. You can find lots of strange examples in error reporting. My favorite one is option -i, which prints the types of top level identifiers, if the file can be compiled. Now, in the situtation, where the inferred types would be most valuable --a type error in the file-- the compiler prints just nothing :-( Bye, Hendrik