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

Functor drop private type information #4933

Closed
vicuna opened this issue Dec 3, 2009 · 3 comments
Closed

Functor drop private type information #4933

vicuna opened this issue Dec 3, 2009 · 3 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 3, 2009

Original bug ID: 4933
Reporter: till
Assigned to: @garrigue
Status: closed (set by @garrigue on 2010-06-07T08:28:11Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.11.0
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #4816

Bug description

module type Priv = sig
type t = private int
end

module Make (Unit:sig end): Priv = struct type t = int end

module A : Priv = Make (struct end)

Additional information

This seems linked to: 4816

@vicuna
Copy link
Author

vicuna commented Dec 7, 2009

Comment author: @garrigue

Actually this is not directly related to 4816 (but I leave the relation anyway, as a reminder)

The problem is just that both for private rows and private abbreviations, strengthening is not monotonous.
Namely, when you define
module A = Make(B)
it actually gets the signature
module A : sig type t = Make(B).t end
Now, if B is not a real module, this is not a valid signature, so the type-checker tries to see if
transform Make(B).t into a valid type. Unfortunately, for private types there is no valid alternative,
so the abbreviation is just discarded, and you get
module A : sig type t end

To avoid this problem you just have to pass a proper module as argument to your functor:
module B = struct end
module A = Make(B)

I still wonder whether it would not be possible to extract the private type information from the
context in this case.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2009

Comment author: @garrigue

Actually, this works with private rows, but the type printed was wrong in that case.
I fixed that in Ctype.nondep_type_decl.

It should also be possible to support the private abbreviation case, by using try_expand_once_opt,
and reinstating the private flag. But this is a bit dangerous...

@vicuna
Copy link
Author

vicuna commented Jun 7, 2010

Comment author: @garrigue

Finally fixed this for private abbreviations too, in revision 10532.

The idea is not to strengthen types when the path is not a valid one.
Unfortunately this seems to solve only a limited number of problems.

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