@@ -191,6 +191,7 @@ type fundef_type_param = {
191191type fundef_term_param = {
192192 attrs : Parsetree .attributes ;
193193 p_label : Asttypes .arg_label ;
194+ lbl_loc : Location .t ;
194195 expr : Parsetree .expression option ;
195196 pat : Parsetree .pattern ;
196197 p_pos : Lexing .position ;
@@ -1594,12 +1595,19 @@ and parse_es6_arrow_expression ?(arrow_attrs = []) ?(arrow_start_pos = None)
15941595 let arrow_expr =
15951596 List. fold_right
15961597 (fun parameter expr ->
1597- let {attrs; p_label = lbl; expr = default_expr; pat; p_pos = start_pos}
1598- =
1598+ let {
1599+ attrs;
1600+ p_label = lbl;
1601+ lbl_loc;
1602+ expr = default_expr;
1603+ pat;
1604+ p_pos = start_pos;
1605+ } =
15991606 parameter
16001607 in
16011608 let loc = mk_loc start_pos end_pos in
1602- Ast_helper.Exp. fun_ ~loc ~attrs ~arity: None lbl default_expr pat expr)
1609+ Ast_helper.Exp. fun_ ~loc ~attrs ~label_loc: lbl_loc ~arity: None lbl
1610+ default_expr pat expr)
16031611 term_parameters body
16041612 in
16051613 let arrow_expr =
@@ -1647,21 +1655,18 @@ and parse_parameter p =
16471655 let lidents = parse_lident_list p in
16481656 Some (TypeParameter {attrs; locs = lidents; p_pos = start_pos}))
16491657 else
1650- let attrs, lbl, pat =
1658+ let attrs, lbl, lbl_loc, pat =
16511659 match p.Parser. token with
16521660 | Tilde -> (
16531661 Parser. next p;
1654- let lbl_name, loc = parse_lident p in
1655- let prop_loc_attr =
1656- (Location. mkloc " res.namedArgLoc" loc, Parsetree. PStr [] )
1657- in
1662+ let lbl_name, lbl_loc = parse_lident p in
16581663 match p.Parser. token with
16591664 | Comma | Equal | Rparen ->
16601665 let loc = mk_loc start_pos p.prev_end_pos in
16611666 ( [] ,
16621667 Asttypes. Labelled lbl_name,
1663- Ast_helper.Pat. var ~attrs: (prop_loc_attr :: attrs) ~loc
1664- (Location. mkloc lbl_name loc) )
1668+ lbl_loc,
1669+ Ast_helper.Pat. var ~attrs ~loc (Location. mkloc lbl_name loc) )
16651670 | Colon ->
16661671 let lbl_end = p.prev_end_pos in
16671672 Parser. next p;
@@ -1670,31 +1675,30 @@ and parse_parameter p =
16701675 let pat =
16711676 let pat = Ast_helper.Pat. var ~loc (Location. mkloc lbl_name loc) in
16721677 let loc = mk_loc start_pos p.prev_end_pos in
1673- Ast_helper.Pat. constraint_ ~attrs: (prop_loc_attr :: attrs) ~loc
1674- pat typ
1678+ Ast_helper.Pat. constraint_ ~attrs ~loc pat typ
16751679 in
1676- ([] , Asttypes. Labelled lbl_name, pat)
1680+ ([] , Asttypes. Labelled lbl_name, lbl_loc, pat)
16771681 | As ->
16781682 Parser. next p;
16791683 let pat =
16801684 let pat = parse_constrained_pattern p in
1681- {
1682- pat with
1683- ppat_attributes = (prop_loc_attr :: attrs) @ pat.ppat_attributes;
1684- }
1685+ {pat with ppat_attributes = attrs @ pat.ppat_attributes}
16851686 in
1686- ([] , Asttypes. Labelled lbl_name, pat)
1687+ ([] , Asttypes. Labelled lbl_name, lbl_loc, pat)
16871688 | t ->
16881689 Parser. err p (Diagnostics. unexpected t p.breadcrumbs);
16891690 let loc = mk_loc start_pos p.prev_end_pos in
16901691 ( [] ,
16911692 Asttypes. Labelled lbl_name,
1692- Ast_helper.Pat. var ~attrs: (prop_loc_attr :: attrs) ~loc
1693- (Location. mkloc lbl_name loc) ))
1693+ lbl_loc,
1694+ Ast_helper.Pat. var ~attrs ~loc (Location. mkloc lbl_name loc) ))
16941695 | _ ->
16951696 let pattern = parse_constrained_pattern p in
16961697 let attrs = List. concat [pattern.ppat_attributes; attrs] in
1697- ([] , Asttypes. Nolabel , {pattern with ppat_attributes = attrs})
1698+ ( [] ,
1699+ Asttypes. Nolabel ,
1700+ Location. none,
1701+ {pattern with ppat_attributes = attrs} )
16981702 in
16991703 match p.Parser. token with
17001704 | Equal -> (
@@ -1719,17 +1723,37 @@ and parse_parameter p =
17191723 Parser. next p;
17201724 Some
17211725 (TermParameter
1722- {attrs; p_label = lbl; expr = None ; pat; p_pos = start_pos})
1726+ {
1727+ attrs;
1728+ p_label = lbl;
1729+ lbl_loc;
1730+ expr = None ;
1731+ pat;
1732+ p_pos = start_pos;
1733+ })
17231734 | _ ->
17241735 let expr = parse_constrained_or_coerced_expr p in
17251736 Some
17261737 (TermParameter
1727- {attrs; p_label = lbl; expr = Some expr; pat; p_pos = start_pos})
1728- )
1738+ {
1739+ attrs;
1740+ p_label = lbl;
1741+ lbl_loc;
1742+ expr = Some expr;
1743+ pat;
1744+ p_pos = start_pos;
1745+ }))
17291746 | _ ->
17301747 Some
17311748 (TermParameter
1732- {attrs; p_label = lbl; expr = None ; pat; p_pos = start_pos})
1749+ {
1750+ attrs;
1751+ p_label = lbl;
1752+ lbl_loc;
1753+ expr = None ;
1754+ pat;
1755+ p_pos = start_pos;
1756+ })
17331757 else None
17341758
17351759and parse_parameter_list p =
@@ -1759,6 +1783,7 @@ and parse_parameters p : fundef_type_param option * fundef_term_param list =
17591783 {
17601784 attrs = [] ;
17611785 p_label = Asttypes. Nolabel ;
1786+ lbl_loc = Location. none;
17621787 expr = None ;
17631788 pat = unit_pattern;
17641789 p_pos = start_pos;
@@ -1773,6 +1798,7 @@ and parse_parameters p : fundef_type_param option * fundef_term_param list =
17731798 {
17741799 attrs = [] ;
17751800 p_label = Asttypes. Nolabel ;
1801+ lbl_loc = Location. none;
17761802 expr = None ;
17771803 pat = Ast_helper.Pat. var ~loc (Location. mkloc ident loc);
17781804 p_pos = start_pos;
@@ -1786,6 +1812,7 @@ and parse_parameters p : fundef_type_param option * fundef_term_param list =
17861812 {
17871813 attrs = [] ;
17881814 p_label = Asttypes. Nolabel ;
1815+ lbl_loc = Location. none;
17891816 expr = None ;
17901817 pat = Ast_helper.Pat. any ~loc () ;
17911818 p_pos = start_pos;
@@ -3007,6 +3034,7 @@ and parse_braced_or_record_expr p =
30073034 {
30083035 attrs = [] ;
30093036 p_label = Asttypes. Nolabel ;
3037+ lbl_loc = Location. none;
30103038 expr = None ;
30113039 pat = Ast_helper.Pat. var ~loc: ident.loc ident;
30123040 p_pos = start_pos;
0 commit comments