Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] strange behaviour with variants and "cannot be generalized"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Beck01, Wolfgang <BeckW@t...>
Subject: [Caml-list] strange behaviour with variants and "cannot be generalized"

I have three files

vtop.ml --------------------------

type 'a t = {
    t_c : 'a;
}

v1.ml ----------------------------

open Vtop

type t = {
    v1_x : int array;
}

let init = `V1 { v1_x = [| 0 |] }

v2.ml ----------------------------

open Vtop

type t= {
    v2_x : int;
}

let init = `V2 { v2_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?

Wolfgang Beck

-------------------
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