Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] type constructor escape its scope
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-10-03 (11:12)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] type constructor escape its scope

On Thu, Oct 03, 2002 at 11:18:18AM +0200, Basile STARYNKEVITCH wrote:

> I've got when compiling with  
>   ocamlc -pp "camlp4o pa_extend.cmo" -I +camlp4 -I . -c 
> the strange message 
> File "", line 60, characters 7-41:
> This expression has type definition_t but is here used with type 'a
> The type constructor definition_t would escape its scope

This happens typically in this situation:
      $ cat
      let x = ref [];;
      type t = C;;
      x := [C];;

      $ ocamlc -c
      File "", line 3, characters 6-7:
      This expression has type t but is here used with type 'a
      The type constructor t would escape its scope

The problem is that at the *definition* of "x", the type "t" does
not exist yet. The type of "x" is deferred, but is actually
"t list ref". But, since "t" is defined after, it would not be
possible to defined it with a type constraint:
      let x = ref ([] : t list);;

I did not look at your example, but search something around that. If it
is some obscur code generated by Camlp4, it can be more difficult: in
this case, I can look at it, if you need.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: