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 MAA10769 for caml-redistribution; Thu, 12 Aug 1999 12:17:39 +0200 (MET DST) 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 PAA23362 for ; Wed, 4 Aug 1999 15:52:40 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id PAA21119 for ; Wed, 4 Aug 1999 15:52:39 +0200 (MET DST) Received: (from fpottier@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA23041; Wed, 4 Aug 1999 15:52:39 +0200 (MET DST) Message-ID: <19990804155239.50895@pauillac.inria.fr> Date: Wed, 4 Aug 1999 15:52:39 +0200 From: Francois Pottier To: caml-list@inria.fr Subject: Weird behavior with mutually recursive type definitions Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.89.1 Sender: weis Hello, I am puzzled by O'Caml 2.02's bizarre behavior regarding mutually recursive type declarations. Let's start by defining a dummy, unary type constructor. type 'a dummy = Dummy (The right-hand side of this definition isn't relevant here; the problem also shows up when 'a dummy is an abstract type constructor, provided by a functor argument.) Then, consider the following type definitions: type 'a t = 'a dummy type specialized = int t The first type declaration simply renames ``dummy'' into ``t'', and the second one creates a specialized instance of it. O'Caml correctly analyzes these declarations. Now, here's the problem. Let's change just one word, and make the type declarations mutually recursive, even though they needn't be: type 'a t = 'a dummy and specialized = int t O'Caml still accepts the code, but this time, it constrains 'a to be equal to int, as if the type constructor t could not be used polymorphically within its own declaration: type 'a t = 'a dummy constraint 'a = int ^^^^^^^^^^^^^^^^^^^ type specialized = int t Why is this? Can someone explain, or is it a typechecker bug? Thanks, -- François Pottier Francois.Pottier@inria.fr http://pauillac.inria.fr/~fpottier/