caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* object type error
@ 2005-09-19  8:44 Michael Wohlwend
  2005-09-19 12:20 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Wohlwend @ 2005-09-19  8:44 UTC (permalink / raw)
  To: caml-list

Hi,

why do I often get this error message? 

( type xxx is a class type and the other class implements this interface)

----------------------Error:
This expression has type
  < (* many methods *); .. >
but is here used with type xxx
Self type cannot be unified with a closed object type
---------------------
I try to get rid of them by adding random type declarations which I mostly 
don't understand :-), but that's not the solution.

What is the reason for that message?

cheers,
 Michael


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] object type error
  2005-09-19  8:44 object type error Michael Wohlwend
@ 2005-09-19 12:20 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2005-09-19 12:20 UTC (permalink / raw)
  To: micha-1; +Cc: caml-list

From: Michael Wohlwend <micha-1@fantasymail.de>

> ( type xxx is a class type and the other class implements this interface)
> 
> ----------------------Error:
> This expression has type
>   < (* many methods *); .. >
> but is here used with type xxx
> Self type cannot be unified with a closed object type
> ---------------------
> I try to get rid of them by adding random type declarations which I mostly 
> don't understand :-), but that's not the solution.
> 
> What is the reason for that message?

It means that type inference results in unifying the type of self
(either from a named self, a {< .. >} expression, or a type
annotation) to an explicit object type. To allow classes to be
extended, the type of self must be left polymorphic.
You can sometimes avoid it by using a coercion (self :> xxx), but this
doesn't work if xxx was not defined in advance, of if it contains
contravariant occurences.
I stop here: you already realize this is a rather hairy problem.

Since there can be many causes, I need to see your code to understand
where the problem comes from.
Another solution if you don't need to inherit from the object you are
defining, is to use an immediate object, as it is allowed to have a
closed type; at least you won't get the above message.

Jacques Garrigue


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-19 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-19  8:44 object type error Michael Wohlwend
2005-09-19 12:20 ` [Caml-list] " Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).