Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] type constructor escape its scope
Hi,

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 pa_filtproto.ml 
> the strange message 
> 
> File "pa_filtproto.ml", 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 foo.ml
      let x = ref [];;
      type t = C;;
      x := [C];;

      $ ocamlc -c foo.ml
      File "foo.ml", 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.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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