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-26 (02:47)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Problem with class method and polymorphic variants
From: Khoo Yit Phang <>

> Thanks for the quick response! I've encountered another strange one  
> that may be related. The code below compiles only if you remove the  
> underscore in the method "_a". The error message is similar to the  
> earlier one, but I think it's a different problem?
> class ['a] node d =
>      object
>          method _d : 'a = d
>          method p (x : 'a) = "<data>"
>      end
> class ['a] pnode data =
>      object (self)
>          inherit ['a] node data
>          (* doesn't compile with the underscore in "_a" *)
>          method _a = self
>          method p = function `P p -> p#name
>      end

The problem seems the same as the previous one, and it goes away with
the latest release310 version of
As to why the name of the method matters, it may be related to the
order in which the checking is done. Since types are graphs, this ends
up being relevant (but only when there is a bug!)

Jacques Garrigue