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 RAA15729; Fri, 10 May 2002 17:02:13 +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 RAA15767 for ; Fri, 10 May 2002 17:02:12 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4AF2Cn08271 for ; Fri, 10 May 2002 17:02:12 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id RAA0000022181; Fri, 10 May 2002 17:02:11 +0200 (MET DST) From: Luc Maranget Message-Id: <200205101502.RAA0000022181@beaune.inria.fr> Subject: Re: [Caml-list] Bug in typing polymorphic variants found To: skaller@ozemail.com.au (John Max Skaller) Date: Fri, 10 May 2002 17:02:11 +0200 (MET DST) Cc: caml-list@inria.fr In-Reply-To: <3CD98643.9080603@ozemail.com.au> from "John Max Skaller" at mai 09, 2002 06:10:43 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Hmmm. That is bug #491 in the bug tracker, > > and its categorized "not a bug" which it clearly is. > > OK. I think I have found it. Heh. Or rather, Ocaml 3.01 > found it for me. There is a bug in the typing of polymophic variants. > > What happens: Ocaml 3.01 reports a type error. > Ocaml 3.04 does not, it crashes at run time instead. > [.. this is confusing but, I think it crashes even when the bug > in my code is fixed .. this is definitely the same problem I > had before and reported in bug #491] > > The offending lines of code are: > > match dcl with > > | `DCL_val_typeof e -> > Hashtbl.add dfns n (id,sr,parent,`SYMDEF_dcl dcl) > > The match is matching on values of type dcl_t > > The value `DCL_val_typeof _ is NOT a member of the type dcl_t, > so this code will never be executed. > > The type of the Hashtable being used here requires the fourth > component of the data part to be of a type which includes > constructor `SYMDEF_dcl of dcl_t. > > Were the above code ever executed, a bad variant would be > glued into the hash table, since the type of dcl is infered to > include `DCL_val_typeof _. > > The *problem* is that the type of the constructor argument > influences its run-time hash? And so the following code, > which IS executed > > | `DCL_val t -> > Hashtbl.add dfns n (id,sr,parent,`SYMDEF_dcl dcl) > ; > > is producing the *wrong* hash for the variant `SYMDEF_dcl dcl, > because the inference engine thinks the type of dcl is something > other than dcl_t. When I do a lookup of the hash table later in another > module, > I get a bad value out, since in *that* module, the correct type of the dcl > is calculated. At least, thats my guess. > > I'll try to make a small example, > my initial attempts have failed. Otherwise, I'll have to post the > bogus code to sourceforge where > the developers can download it. Hello, Typing of polymorphic variants has much changed in 3.XX versions. Pattern matching compilation of polymorphic variants included a serious bug in 3.01 (or in 3.02, 3.03 I do not remember) version, and the effect of this bug would be what you describe. [If you are interested, this is bug number 359, fixed] This PM bug is corrected in version 3.04. Please consider that we do need running code that shows the erroneous behavior w .r. t. the current version of the compiler. Making assumpsions based upon the previous versions of the compiler is a bit delicate here, since two parts that look critical to your report underwent important modifications. --Luc Maranget ------------------- 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