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: j h woodyatt <jhw@c...>
Subject: spurious warning? "polymorphic method not principal"
everyone--

Please, consider the following test case:

> (* 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?   
(Perhaps, the word "principal" in this context doesn't mean what I  
think it means.)

Or is it a bug in the compiler?  If it isn't a bug in the compiler,  
could someone please explain to me why my program produced this  
warning?  Thank you very much.


—
j h woodyatt <jhw@conjury.org>