Version française
Home     About     Download     Resources     Contact us    
Browse thread
spurious warning? "polymorphic method not principal"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] spurious warning? "polymorphic method not principal"
From: j h woodyatt <jhw@conjury.org>

> > (* test.ml *)
> > class alfa = object(_:'self)
> >   method x: 'a. ('a, out_channel, unit) format -> 'a = Printf.printf
> > end
> >
> > class bravo a = object
> >   val y: alfa = (a :> alfa)
> >   initializer y#x "bravo initialized"
> > end
> >
> > class charlie a = object
> >   inherit bravo a
> >   initializer y#x "charlie initialized"
> > end
> 
> $ ocamlc -principal -o test test.ml
> File "test.ml", line 13, characters 14-17:
> Warning X: this use of a polymorphic method is not principal.
> 
> It warns about the use of the polymorphic method on the object in the  
> membership of the base class, but only when it's invoked from the  
> derived class.  This confuses me.  Is this a bug in my code?   

No, this is a bug in the compiler. I'll try to fix it.

Jacques Garrigue