Navigation Menu

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" leaves weak polymorphic types in module type #5036

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

Comments

@vicuna
Copy link

vicuna commented Apr 24, 2010

Original bug ID: 5036
Reporter: kaustuv
Status: closed (set by @garrigue on 2010-04-30T05:13:39Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: "Julien Signoles" @hcarty

Bug description

module type S =

   module type of (struct
                    let f = (fun x -> x) (fun x -> x)
                   end) ;;

module type S = sig val f : '_a -> '_a end

Light experimentation suggests that only modules that define a value f : 'a. 'a -> 'a will ascribe to the above signature, so "module type of" should promote weak polymorphic types to strong polymorphic types.

@vicuna
Copy link
Author

vicuna commented Apr 28, 2010

Comment author: @xavierleroy

I'm not comfortable with generalizing these type variables automatically. Added a check to reject "module type of M" if "M" contains nongeneralized type variables.

@vicuna
Copy link
Author

vicuna commented Apr 28, 2010

Comment author: kaustuv

Many apologies for reopening this with a trivial nitpick, but you got the test for closedness and the simplification (#5037) in the wrong order in typing/typemod.ml/type_module_type_of. Witness this startling result:

module M = struct let f = (fun x -> x) (fun x -> x) let f x = x end ;;

module M : sig val f : 'a -> 'a end

module type S = module type of M ;;

Error: The type of this module, sig val f : '_a -> '_a val f : 'a -> 'a end,
contains type variables that cannot be generalized

@vicuna
Copy link
Author

vicuna commented Apr 30, 2010

Comment author: @garrigue

Indeed, type_implementation was doing it in the opposite order.
Fixed in revision 10330.

@vicuna vicuna closed this as completed Apr 30, 2010
@vicuna vicuna added the bug label Mar 20, 2019
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