Consider the following small example:
type 'r foo_t = <get : 'r bar option ; set : 'r bar option -> 'r; ..> as 'r
and 'r bar
constraint 'r = 'r foo_t
class c : object('r)
constraint 'r = 'r foo_t
method get : 'r bar option
method set : 'r bar option -> 'r
end
The concept here is, that class c
can have elements of type bar
which may in turn (somehow) reference to class c
's complete representation. So by inheriting from class c
, the concrete type for 'r
gets updated with the complete class we have constructed.
The problem is: This interface crashes the typechecker. And I don't see why:
choeger@daishi /tmp % ocamlc -v
The OCaml compiler, version 4.00.1
Standard library directory: /usr/lib64/ocaml
choeger@daishi /tmp % ocamlc -c -annot -o test.cmi test.mli
Fatal error: exception Assert_failure("typing/ctype.ml", 246, 27)
So any hints on why this is problematic, or how this bahaves with different versions of OCaml are very much appreciated.