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

Module constraint + private type seems brocken in ocaml 4.01.0 #6090

Closed
vicuna opened this issue Jul 26, 2013 · 3 comments
Closed

Module constraint + private type seems brocken in ocaml 4.01.0 #6090

vicuna opened this issue Jul 26, 2013 · 3 comments

Comments

@vicuna
Copy link

@vicuna vicuna commented Jul 26, 2013

Original bug ID: 6090
Reporter: jpdeplaix
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:21:20Z)
Resolution: fixed
Priority: high
Severity: major
Fixed in version: 4.01.0+dev
Category: typing
Monitored by: @gasche @hcarty

Bug description

The following test-case doesn't compile using ocaml-4.01.0 but does compile with older versions.

It produce the following error:
Error: This variant or record definition does not match that of type Test.t
A private type would be revealed.

Steps to reproduce

module Test = struct type t = private A end
module Test2 : module type of Test with type t = Test.t = Test

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 26, 2013

Comment author: @garrigue

Actually, I wonder which older versions you are talking about.
I tested with 3.12.1 and 4.00.1, and in both cases your code is refused
(albeit for a different reason).

This said, now that a with constraint adds equations rather than overwrite
the original definition, it makes sense to allow this.
This is now accepted in 4.01 and trunk (revisions 13936 and 13937)

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 27, 2013

Comment author: jpdeplaix

Ok, sorry. It was a wrong test-case. But, good news, it seems to fix the original case. So, thanks.

The original case was in eliom, in this file line 100:
http://ocsigen.org/darcsweb/?r=eliom.dev;a=headblob;f=/src/server/eliom_content_core.mli
and it fails to compile with 4.01.0 with the same error than the test-case (after replacing Test.t with Xml.acontent).

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 31, 2013

Comment author: @garrigue

For backward compatibility reasons, we need to allow using private in the with clause in that case:

module Test = struct type t = private A end
module Test2 : (module type of Test with type t = private Test.t) = Test

This was the only way to obtain the expected behavior in 3.12 and 4.00, and is used actively in Core.

I have added a deprecation warning in trunk (but not 4.00), since this use of private is not semantically correct.

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

Successfully merging a pull request may close this issue.

None yet
2 participants