| Anonymous | Login | Signup for a new account | 2013-05-18 11:28 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 | |||
| 0004745 | OCaml | OCaml general | public | 2009-03-15 19:53 | 2009-03-16 05:25 | |||
| Reporter | silroquen | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.11.0 | |||||||
| Target Version | Fixed in Version | 3.11.1+dev | ||||||
| Summary | 0004745: inferred type with a weak type variable that maybe shouldn't be | |||||||
| Description | Here is a simple linked list type: type 'a linked_list = 'a node option and 'a node = { value : 'a; next : 'a linked_list; } and three apparently equivalent functions to find the linked list's last node: let rec find_end_a = function | None -> None | Some {next = None} as li -> li | Some node -> find_end_a node.next let rec find_end_b = function | None -> None | Some {next = None} as li -> li | Some {next = n} -> find_end_b n let rec find_end_c = function | None -> None | Some {next = None} as li -> li | Some {next = Some n} -> find_end_c (Some n) Note that the inferred type for find_end_a and find_end_b is '_a linked_list -> '_a node option but, for find_end_c: 'a node option -> 'a node option It seems like all three functions should have the type of find_end_c. | |||||||
| Additional Information | Note that if the linked_list type is eliminated, so instead type 'a node = { value : 'a; next : 'a node option } then the functions find_end_* all have type 'a node option -> 'a node option as expected. | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0004855) garrigue (manager) 2009-03-16 05:25 |
Thanks for pointing this subtle bug, that appears only in the toplevel. This was due to side-effects to types during compilation... Solved by taking clean copies when needed. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2009-03-15 19:53 | silroquen | New Issue | |
| 2009-03-16 05:25 | garrigue | Note Added: 0004855 | |
| 2009-03-16 05:25 | garrigue | Status | new => closed |
| 2009-03-16 05:25 | garrigue | Resolution | open => fixed |
| 2009-03-16 05:25 | garrigue | Fixed in Version | => 3.11.1+dev |
| Copyright © 2000 - 2011 MantisBT Group |