Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006235OCamlOCaml typingpublic2013-11-12 14:162013-11-13 01:19
Reporterfrisch 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.01.1+dev 
Summary0006235: Issue with type information flowing through a variant pattern
DescriptionAs reported by Bob Zhang on the caml-list:

type t = { loc : string; }
type v = { loc : string; x : int; }
type u = [ `Key of t ]
let f (u : u) = match u with `Key {loc} -> loc;;
                             ^^^^^^^^^^
Error: This pattern matches values of type [? `Key of v ]
       but a pattern was expected which matches values of type u
       Types for tag `Key are incompatible


This is surprising, because:

 let f (u : u) = match u with `Key loc -> loc.loc


works fine.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010619)
hongboz (developer)
2013-11-12 15:39

The link: https://sympa.inria.fr/sympa/arc/caml-list/2013-10/msg00172.html [^]
(0010623)
garrigue (manager)
2013-11-13 01:19

Fixed in 4.01 and trunk, revisions 14284 and 14285.

In trunk, also made principal mode a bit more strict, by keeping different branches of a pattern-matching independent when typing patterns.
I.e., assuming the same type definitions, the following function is refused in principal mode (but accepted in standard mode).

  let f = function
    | (_ : u) when false -> ""
    |`Key {loc} -> loc

Rationale for refusing this: changing the order of branches breaks the typing.

- Issue History
Date Modified Username Field Change
2013-11-12 14:16 frisch New Issue
2013-11-12 15:39 hongboz Note Added: 0010619
2013-11-13 01:19 garrigue Note Added: 0010623
2013-11-13 01:19 garrigue Status new => resolved
2013-11-13 01:19 garrigue Fixed in Version => 4.01.1+dev
2013-11-13 01:19 garrigue Resolution open => fixed
2013-11-13 01:19 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker