Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive class type definition via module rec misses some inheritance information #5388

Closed
vicuna opened this issue Oct 26, 2011 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 26, 2011

Original bug ID: 5388
Reporter: furuse
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2013-08-31T10:44:02Z)
Resolution: not fixable
Priority: normal
Severity: major
Version: 3.12.1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche

Bug description

The 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.

@vicuna
Copy link
Author

vicuna commented Oct 27, 2011

Comment author: furuse

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

@vicuna
Copy link
Author

vicuna commented Oct 29, 2011

Comment author: @garrigue

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants