@@ -4892,16 +4892,30 @@ and parse_type_constructor_declaration_with_bar p =
4892
4892
[doc_comment_to_attribute loc s]
4893
4893
| _ -> []
4894
4894
in
4895
+ let has_doc_comment = not (doc_comment_attrs = [] ) in
4895
4896
match p.Parser. token with
4896
4897
| Bar ->
4897
4898
let start_pos = p.Parser. start_pos in
4898
4899
Parser. next p;
4899
4900
let constr = parse_type_constructor_declaration ~start_pos p in
4901
+ let pcd_loc =
4902
+ if has_doc_comment then
4903
+ {
4904
+ constr.Parsetree. pcd_loc with
4905
+ loc_end =
4906
+ {
4907
+ constr.pcd_loc.loc_end with
4908
+ pos_lnum = constr.pcd_loc.loc_end.pos_lnum + 1 ;
4909
+ };
4910
+ }
4911
+ else constr.pcd_loc
4912
+ in
4900
4913
Some
4901
4914
{
4902
4915
constr with
4903
4916
Parsetree. pcd_attributes =
4904
4917
doc_comment_attrs @ constr.Parsetree. pcd_attributes;
4918
+ pcd_loc;
4905
4919
}
4906
4920
| _ -> None
4907
4921
@@ -4939,10 +4953,27 @@ and parse_type_constructor_declarations ?first p =
4939
4953
[doc_comment_to_attribute loc s]
4940
4954
| _ -> []
4941
4955
in
4956
+ let has_doc_comment = not (doc_comment_attrs = [] ) in
4942
4957
let start_pos = p.Parser. start_pos in
4943
4958
ignore (Parser. optional p Token. Bar );
4944
4959
let constr = parse_type_constructor_declaration ~start_pos p in
4945
- {constr with pcd_attributes = doc_comment_attrs @ constr.pcd_attributes}
4960
+ let pcd_loc =
4961
+ if has_doc_comment then
4962
+ {
4963
+ constr.Parsetree. pcd_loc with
4964
+ loc_end =
4965
+ {
4966
+ constr.pcd_loc.loc_end with
4967
+ pos_lnum = constr.pcd_loc.loc_end.pos_lnum + 1 ;
4968
+ };
4969
+ }
4970
+ else constr.pcd_loc
4971
+ in
4972
+ {
4973
+ constr with
4974
+ pcd_attributes = doc_comment_attrs @ constr.pcd_attributes;
4975
+ pcd_loc;
4976
+ }
4946
4977
| Some first_constr_decl -> first_constr_decl
4947
4978
in
4948
4979
first_constr_decl
0 commit comments