Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007582OCamllanguage featurespublic2017-07-11 22:052017-07-12 00:23
Reporterygrek 
Assigned Togasche 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionduplicate 
PlatformOSOS Version
Product Version4.04.1 
Target VersionFixed in Version 
Summary0007582: propapate type disambiguation to the record pattern
DescriptionGiven the following

module T = struct type t = { a : int; b : float } let create a b = { a; b } end;;

(1) Type of the returned value is propagated to the binding and compiler can resolve record fields just fine :

let unwrap () = let x = T.create 1 2. in (x.a,x.b);;

(2) But substituting with record pattern doesn't work :

let unwrap () = let {a;b} = T.create 1 2. in (a,b);;
Error: Unbound record field a

(3) Have to explicitly annotate record type :

let unwrap () = let {T.a;b} = T.create 1 2. in (a,b);;


Seems like a common pattern in code, would be nice to make (2) work?
Additional InformationSame behaviour in 4.04.1 and 4.05.0+rc1
TagsNo tags attached.
Attached Files

- Relationships
duplicate of 0007389acknowledgedgarrigue Can type-information flow be strengthened for non-recursive lets? 

-  Notes
(0018062)
gasche (developer)
2017-07-11 23:13

I asked the same question in PR#7389, but it turns out (see discussion there) that it is actually not easy to do this in a general and satisfying way.
(0018063)
ygrek (reporter)
2017-07-12 00:15

Thanks, I looked for the duplicate but couldn't find it
(0018064)
gasche (developer)
2017-07-12 00:23

Yeah, my title choice was pretty bad. No worries!

- Issue History
Date Modified Username Field Change
2017-07-11 22:05 ygrek New Issue
2017-07-11 23:13 gasche Note Added: 0018062
2017-07-11 23:13 gasche Relationship added duplicate of 0007389
2017-07-11 23:13 gasche Status new => resolved
2017-07-11 23:13 gasche Resolution open => duplicate
2017-07-11 23:13 gasche Assigned To => gasche
2017-07-12 00:15 ygrek Note Added: 0018063
2017-07-12 00:23 gasche Note Added: 0018064


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker