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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8CD20D45F for ; Tue, 1 Nov 2005 17:17:45 +0100 (CET) Received: from cenn.mc.mpls.visi.com (cenn.mc.mpls.visi.com [208.42.156.9]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA1GHiP8008400 for ; Tue, 1 Nov 2005 17:17:45 +0100 Received: from [192.168.42.2] (bhurt.dsl.visi.com [208.42.141.66]) by cenn.mc.mpls.visi.com (Postfix) with ESMTP id 79C1581EB; Tue, 1 Nov 2005 10:17:44 -0600 (CST) Date: Tue, 1 Nov 2005 10:21:05 -0600 (CST) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Jonathan Roewen Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Type inference problem In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at nez-perce with ID 43679528.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 inference:01 stdlib:01 ocamlc:01 annotations:01 ocaml:01 annotation:01 ocaml:01 2005,:98 wrote:01 complains:01 expression:01 explicitly:01 int:01 int: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 Tue, 1 Nov 2005, Jonathan Roewen wrote: > Hi, > > I can't figure out what's wrong with my code =( > > It's on a paste site, so will only last about 24 hours or so. > http://rafb.net/paste/results/Uux57B97.html > > jonathan@moonbeam:~/dst/stdlib$ ocamlc VFS.ml > File "VFS.ml", line 106, characters 3-6: > This expression has type int but is here used with type unit > > It -has- to return int ;-) But I have no idea where the type > constraint is coming from that wants it to return unit. Change it to > return unit, and where it's used complains it doesn't return type int > (so that constraint is correct). A general tactic I use in cases like this is to add type annotations. What is almost certainly happening is that somewhere else before this line in your code you are returning unit as a value, so Ocaml thinks it's supposed to return unit. If you add a type annotation to explicitly state that it returns int, Ocaml will instead give an error where you return unit, allowing you to fix the problem. Brian