You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: