| Anonymous | Login | Signup for a new account | 2013-05-25 12:29 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 | |||
| 0004382 | OCaml | OCaml general | public | 2007-09-05 20:44 | 2007-09-06 04:21 | |||
| Reporter | mottl | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.10+dev | |||||||
| Target Version | Fixed in Version | 3.10+dev | ||||||
| Summary | 0004382: Strange typing restriction with polymorphic record fields | |||||||
| Description | In the following example I match + bind a record with a polymorphic field. The bound function is fully polymorphic and works without problems: ---------------------------------------- type t = { id : 'a. 'a -> 'a } let mk_id () = { id = fun x -> x } let { id = id } = mk_id () let () = let x = id 0 in let y = id 0. in Printf.printf "%d %f\n" x y ---------------------------------------- But if I replace the line with the pattern match on the record field by the following: let { id = id } as t = mk_id () then I get a type error: File "foo.ml", line 9, characters 13-15: This expression has type float but is here used with type int It seems strange that adding the "as t" binding, which is not even used, would suddenly make "id" not fully polymorphic anymore, especially since the following, which should be semantically equivalent, works again: let t = mk_id () let { id = id } = t It is worth pointing out that OCaml 3.09.3 doesn't compile any but the most recent example. It would be great if type inference in the above cases could be made more predictable and/or general. | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0004144) garrigue (manager) 2007-09-06 04:21 |
Fixed by avoid polymorphic fields in Typecore.build_as_type. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2007-09-05 20:44 | mottl | New Issue | |
| 2007-09-06 04:21 | garrigue | Status | new => closed |
| 2007-09-06 04:21 | garrigue | Note Added: 0004144 | |
| 2007-09-06 04:21 | garrigue | Resolution | open => fixed |
| 2007-09-06 04:21 | garrigue | Fixed in Version | => 3.10+dev |
| Copyright © 2000 - 2011 MantisBT Group |