Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005388OCamlOCaml generalpublic2011-10-26 20:342013-08-31 12:44
Reporterfuruse 
Assigned Togarrigue 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionnot fixable 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005388: recursive class type definition via module rec misses some inheritance information
DescriptionThe following code is not type-checked:

----------------------------

type 'a t

type _Unicode
type _String
type _Sequence

module rec M_Sequence : sig
  class type o_Sequence = object method _Sequence : _Sequence t end
end = struct
  class type o_Sequence = object method _Sequence : _Sequence t end
end

and M_String : sig
  class type o_String = object inherit M_Sequence.o_Sequence method _String : _String t end
end = struct
  class type o_String = object inherit M_Sequence.o_Sequence method _String : _String t end
end

and M_Unicode : sig
  class type o_Unicode = object inherit M_String.o_String method _Unicode : _Unicode t end
end = struct
  class type o_Unicode = object inherit M_String.o_String method _Unicode : _Unicode t end
end

---------------

Saying:
       class type o_Unicode =
           object method _String : _String t method _Unicode : _Unicode t end
       The public method _Sequence cannot be hidden

So, there is something strange around the conjunction of module rec and class inheritance.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0006187)
furuse (reporter)
2011-10-27 02:34

Now I have something simpler and working, but still the above example indicates a bug of computing the fixed point of inheritance...

------------------------------

type 'a t
 
type _Unicode
type _String
type _Sequence
 
module rec M : sig
  class type o_Sequence = object method _Sequence : _Sequence t end
  class type o_String = object inherit M.o_Sequence method _String : _String t end
  class type o_Unicode = object inherit M.o_String method _Unicode : _Unicode t end
end = M
(0006192)
garrigue (manager)
2011-10-29 10:45

My understanding is that computation of fixpoints for recursive modules is incomplete,
and cannot even be so from a theoretical point of view (impossible to know the number
of iterations needed to reach a fixpoint).

For classes, the algorithm is bootstrapped by starting from empty classes, which explains
why inheritance doesn't work when the number of modules involved is too large.
Since I don't see any complete solution coming, the best approach is to avoid
inheritance between recursive modules.

By the way, I don't know why your workaround using a single interface works,
but this seems to scale for an arbitrary number of levels of inheritance. Good.

- Issue History
Date Modified Username Field Change
2011-10-26 20:34 furuse New Issue
2011-10-27 02:34 furuse Note Added: 0006187
2011-10-29 10:45 garrigue Note Added: 0006192
2011-12-21 11:54 gasche Status new => resolved
2011-12-21 11:54 gasche Resolution open => not fixable
2011-12-21 11:54 gasche Assigned To => garrigue
2013-08-31 12:44 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker