From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 26390BB84 for ; Thu, 19 Jun 2008 04:17:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAAReWUiCNhAB/2dsb2JhbACxEQ X-IronPort-AV: E=Sophos;i="4.27,669,1204498800"; d="scan'208";a="14066218" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Jun 2008 04:17:13 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m5J2HC2x024132 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 19 Jun 2008 04:17:12 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAAReWUiCNhAB/2dsb2JhbACxEQ X-IronPort-AV: E=Sophos;i="4.27,669,1204498800"; d="scan'208";a="14066217" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Jun 2008 04:17:11 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id m5J2H5SJ002145; Thu, 19 Jun 2008 11:17:05 +0900 (JST) Date: Thu, 19 Jun 2008 11:16:53 +0900 (JST) Message-Id: <20080619.111653.160746609.garrigue@math.nagoya-u.ac.jp> To: mshinwell@janestcapital.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Type checker (ex-)bug From: Jacques Garrigue In-Reply-To: <20080618182140.GK30596@janestcapital.com> References: <20080618182140.GK30596@janestcapital.com> X-Mailer: Mew version 4.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4859C1A8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; checker:01 bug:01 shinwell:01 typecheck:01 ocamlc:01 compiler:01 foo:01 bug:01 btype:01 iter:01 btype:01 typecore:01 polymorphism:01 polymorphism:01 snap:98 From: "Mark Shinwell" > The following program: > > type 'a s = 'a > type 'a t = unit > > let g (_ : 'a s -> unit) (_ : 'a t) = () > let f t = g (fun x -> x; ()) t > > fails to typecheck using ocamlc 3.10.0 but succeeds (as would surely be > expected) under 3.10.1 and 3.10.2. The 3.10.0 compiler complains: > > File "foo.ml", line 5, characters 6-30: > The type of this expression, '_a t -> unit, > contains type variables that cannot be generalized > > The fix for this bug doesn't appear to be explicitly noted in the Changes > file, but it was fixed by this patch, which was introduced between 3.10.0 > and 3.10.1: > > @@ -585,8 +585,11 @@ > let add_delayed_check f = delayed_checks := f :: !delayed_checks > let force_delayed_checks () = > + (* checks may change type levels *) > + let snap = Btype.snapshot () in > List.iter (fun f -> f ()) (List.rev !delayed_checks); > - reset_delayed_checks () > + reset_delayed_checks (); > + Btype.backtrack snap > > Could someone comment whether this patch is indeed the correct fix for > this problem (I assume it was written to fix something else)? Or is > there perhaps still something wrong that is being masked by this patch? Indeed, the fix for PR#4350 is in typecore.ml/1.190.2.5, and it is about delayed checks changing type levels, and losing polymorphism. In you specific case, this is the delayed check about sequences (here you should have a warning if x has a concrete type other than unit). So yes, this is the fix you need to avoid the above problem, and other loss of polymorphism related to delayed checks. Jacques Garrigue