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

3.12.0+dev18: "module type of" produces unusable signatures for repeated definitions #5037

Closed
vicuna opened this issue Apr 24, 2010 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 24, 2010

Original bug ID: 5037
Reporter: kaustuv
Status: closed (set by @garrigue on 2010-04-28T05:04:18Z)
Resolution: fixed
Priority: normal
Severity: major
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #6252 #4487 #4974 #5061
Monitored by: "Julien Signoles" @hcarty

Bug description

module type S = module type of (struct

                                   let x = 42
                                   let x = "abc"
                                 end) ;;

module type S = sig val x : int val x : string end

module T : S = struct let x = "abc" end ;;

Characters 15-39:
module T : S = struct let x = "abc" end ;;
^^^^^^^^^^^^^^^^^^^^^^^^
Error: Signature mismatch:
Modules do not match: sig val x : string end is not included in S
Values do not match: val x : string is not included in val x : int

These don't work either:

module T : S = struct let x = 42 end ;;

module T : S = struct let x = 42 let x = "abc" end ;;

Since repeated module level definitions with the same name are very common, "module type of" should use the same heuristic as "sig ... end" and retain only the last one of repeated definitions.

File attachments

@vicuna
Copy link
Author

vicuna commented Apr 26, 2010

Comment author: Julien Signoles

This issue is not specific to "module type of". See BTS entries #1441, #4487 and #4974.

@vicuna
Copy link
Author

vicuna commented Apr 26, 2010

Comment author: kaustuv

0001441 and 0004487 are not relevant because their error conditions are no longer reproducible:

module type S = sig val x : int val x : string end ;;

module type S = sig val x : string end

That is, it appears that sig ... end now drops all but the last of duplicate definitions.

0004974 is possibly not relevant either, but there isn't enough code there for me to judge.

@vicuna
Copy link
Author

vicuna commented Apr 26, 2010

Comment author: kaustuv

Attached patch against r10311 that suggests a possible fix. There is probably a better way to do it, though.

@vicuna
Copy link
Author

vicuna commented Apr 28, 2010

Comment author: @garrigue

Just needed to call simplify_modtype on the generated signature.
Fixed for 3.12.

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

1 participant