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

The name of types introduced by (type foo) are not used for the inferred type variables #5450

Closed
vicuna opened this Issue Dec 23, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Dec 23, 2011

Original bug ID: 5450
Reporter: pilki
Assigned to: @garrigue
Status: closed (set by @garrigue on 2011-12-27T09:01:47Z)
Resolution: fixed
Severity: feature
Fixed in version: 3.13.0+dev
Category: ~DO NOT USE (was: OCaml general)
Child of: #5444
Monitored by: @protz

Bug description

If you write
<<<
let f (x:'foo) = x

the inferred type is
val f : 'foo -> 'foo

but if you write
<<<
let g (type bar) (x:bar) = x

you end up with
val g : 'a -> 'a
instead of
val g : 'bar -> 'bar

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 24, 2011

Comment author: @garrigue

As mentioned in #5445, this is a consequence of dropping variable names upon instantiation.
We probably need to do something in this case, as we clearly want to keep those explicit names, at least in the current function definition.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 27, 2011

Comment author: @garrigue

Fixed in revision 11958.

Note that this also solves the same problem for explicit polymorphism:

let id : 't. 't -> 't = fun x -> x;;

val id : 't -> 't =

let id : type foo. foo -> foo = fun x -> x;;

val id : 'foo -> 'foo =

Potential glitch (but not new):

let magic : type t t'. t -> t' = Obj.magic;;

val magic : 't -> 't' =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.