From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA30787; Tue, 9 Sep 2003 14:11:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 OAA23919 for ; Tue, 9 Sep 2003 14:11:51 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h89CBnf01914 for ; Tue, 9 Sep 2003 14:11:50 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id VAA06474; Tue, 9 Sep 2003 21:11:41 +0900 (JST) To: BeckW@t-systems.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] strange behaviour with variants and "cannot be generalized" In-Reply-To: References: X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030909211156G.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 09 Sep 2003 21:11:56 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 t-systems:01 struct:01 compiles:01 3.06.:01 3.07:01 jacques:01 arrays:01 ocaml:01 mutable:01 variants:01 int:01 garrigue:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: "Beck01, Wolfgang" > v1.ml ---------------------------- > > open Vtop > > type t = { > v1_x : int array; > } > > let init = `V1 { v1_x = [| 0 |] } > > compilation fails with "The type of this expression _[> `V1 of t ] Vtop.t, > contains type variables that cannot be generalized" > > However, if I change the type of v1_x to a string or some large struct, > it compiles without warning and works. The error seems only to occur > with arrays. I am using version 3.06. > > Is there an explanation for this behaviour? Sure: [| 0 |] creates a mutable data structure, and as such is considered as a side-effecting expression. As a result the type of init cannot be generalized. OCaml 3.07 is more clever about that, and the above program would be accepted with no problem. Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners