| Anonymous | Login | Signup for a new account | 2013-05-23 18:05 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0005663 | OCaml | OCaml typing | public | 2012-06-26 16:28 | 2012-09-21 14:36 | ||||||
| Reporter | sweeks | ||||||||||
| Assigned To | garrigue | ||||||||||
| Priority | normal | Severity | minor | Reproducibility | always | ||||||
| Status | assigned | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | |||||||||||
| Target Version | 4.01.0+dev | Fixed in Version | |||||||||
| Summary | 0005663: program (mistakenly?) rejected due to nongeneralizable type variable that appears nowhere | ||||||||||
| Description | The program below is rejected by the type checker. module F (M : sig type 'a v = string include sig type 'a t type 'a u val f : unit -> _ t val g : 'a t -> 'a u -> unit end with type 'a u := 'a v end) = struct open M let t = (f () (*: unit v t*)) (* uncomment here to make it type check *) let () = g t "foo" end The error message is: Error: The type of this module, functor (M : sig type 'a v = string type 'a t val f : unit -> 'a t val g : 'a t -> 'a v -> unit end) -> sig val t : '_a M.t end, contains type variables that cannot be generalized I think this program should be accepted. The type variable that OCaml is complaining about is unused, if one expands out the types. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0007610) garrigue (manager) 2012-06-26 16:59 |
I'm not sure I understand your point here. It seems that M.t is abstract in this program, so you cannot expand it. So the type variable is really there, even if you didn't name it. Writing "type +'a t" would probably solve the problem, if this is acceptable. |
|
(0007806) sweeks (reporter) 2012-07-24 20:47 |
Sorry, my example had a mistake. Here is a much simpler example: module F (M : sig type 'a t type 'a u = string val f : unit -> _ u t end) = struct let t = M.f () end This causes the following error message: Error: The type of this module, functor (M : sig type 'a t type 'a u = string val f : unit -> 'a u t end) -> sig val t : '_a M.u M.t end, contains type variables that cannot be generalized The type variable that OCaml is complaining about, ['_a], is in the expression ['_a M.u], which OCaml knows is equivalent to [string]. I don't see why OCaml should be complaining about ['_a], since it need not appear in the type of [t], which has type [string M.t]. Adding a type constraint to [t] of the form [string M.t] isn't sufficient to make the error go away. However, adding a type constraint [unit M.u M.t] does make the error go away. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2012-06-26 16:28 | sweeks | New Issue | |
| 2012-06-26 16:59 | garrigue | Note Added: 0007610 | |
| 2012-06-26 16:59 | garrigue | Assigned To | => garrigue |
| 2012-06-26 16:59 | garrigue | Status | new => feedback |
| 2012-07-06 15:21 | doligez | Target Version | => 4.01.0+dev |
| 2012-07-24 20:47 | sweeks | Note Added: 0007806 | |
| 2012-07-24 20:47 | sweeks | Status | feedback => assigned |
| 2012-07-31 13:36 | doligez | Target Version | 4.01.0+dev => 4.00.1+dev |
| 2012-09-21 14:36 | doligez | Target Version | 4.00.1+dev => 4.01.0+dev |
| Copyright © 2000 - 2011 MantisBT Group |