Anonymous | Login | Signup for a new account | 2017-05-30 11:23 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 | |||

0006256 | OCaml | typing | public | 2013-12-02 00:40 | 2015-12-11 19:25 | |||

Reporter | sebmondet | |||||||

Assigned To | garrigue | |||||||

Priority | normal | Severity | major | Reproducibility | always | |||

Status | closed | Resolution | no change required | |||||

Platform | OS | OS Version | ||||||

Product Version | 4.01.0 | |||||||

Target Version | Fixed in Version | |||||||

Summary | 0006256: Open Polymorphic Variants, difference between 4.00.1 and 4.01.0 | |||||||

Description | This code used to compile fine with 4.00.1: module type T = sig type t val f : t -> ([> `A | `B ] -> t) -> t end module Tt : T = struct type t = [ `A | `B ] let f t g = g (t :> [> `A | `B]) end but with 4.01.0, I get: Error: Signature mismatch: Modules do not match: sig type t = [ `A | `B ] val f : ([> `A | `B ] as 'a) -> ('a -> 'b) -> 'b end is not included in T Values do not match: val f : ([> `A | `B ] as 'a) -> ('a -> 'b) -> 'b is not included in val f : t -> ([> `A | `B ] -> t) -> t PS: Is there a more future proof work-around that does not imply expanding a match-with? like this: module Tt : T = struct type t = [ `A | `B ] let f t g = match t with | `A -> g `A | `B -> g `B end | |||||||

Tags | No tags attached. | |||||||

Attached Files | ||||||||

Notes | |

(0010685) garrigue (manager) 2013-12-02 03:17 |
If you look at the type inferred in 4.00 (and previous version) you can see that this is a bug in the type subsumption check, which was fixed in 4.01: # module Tt = struct type t = [ `A | `B ] let f t g = g (t :> [> `A | `B]) end;; module Tt : sig type t = [ `A | `B ] val f : ([> `A | `B ] as 'a) -> ('a -> 'b) -> 'b end Clearly the type inferred for f does not contain "t -> [> `A | `B] -> t -> t", as it requires that t and the argument of g have the same type. The right way to write f is: # let f (#t as t) g = g t;; val f : [< t ] -> ([> t ] -> 'a) -> 'a |

Issue History | |||

Date Modified | Username | Field | Change |

2013-12-02 00:40 | sebmondet | New Issue | |

2013-12-02 03:17 | garrigue | Note Added: 0010685 | |

2013-12-02 03:17 | garrigue | Status | new => resolved |

2013-12-02 03:17 | garrigue | Resolution | open => no change required |

2013-12-02 03:17 | garrigue | Assigned To | => garrigue |

2015-12-11 19:25 | xleroy | Status | resolved => closed |

2017-02-23 16:45 | doligez | Category | OCaml typing => typing |

Copyright © 2000 - 2011 MantisBT Group |