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
Problem with class method and polymorphic variants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-06-25 (03:12)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Problem with class method and polymorphic variants
From: Khoo Yit Phang <>
> Hi,
> I discovered that the attached snippet of Ocaml does not compile in  
> ocamlc, but does work in the ocaml toplevel (tested in v3.10.0 and  
> 3.10.2). Removing anything (except the :int annotation) causes the  
> error to go away. Is it a bug in the type-checker?
> # cat
> class ['a] c (a : 'a) =
>     object (s)
>         method s = s
>         method d : int = match a with `A b -> b#num
>     end

Of course this is a bug. I added it myself to the bug tracker.
By the way you could also trigger it in the toplevel by giving
explicitly a module signature (this is what ocamlc does internally).

This is now fixed in CVS, branch release310.
Note that you may still have other kinds of problems using
upper-bounded polymorpic variants inside constraints. Just report them
as you go...


Jacques Garrigue