-
Notifications
You must be signed in to change notification settings - Fork 1.2k
propapate type disambiguation to the record pattern #7582
Description
Original bug ID: 7582
Reporter: @ygrek
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-07-11T21:13:47Z)
Resolution: duplicate
Priority: normal
Severity: feature
Version: 4.04.1
Category: language features
Duplicate of: #7389
Bug description
Given 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 information
Same behaviour in 4.04.1 and 4.05.0+rc1