@@ -417262,6 +417262,7 @@ let log t =
417262
417262
]
417263
417263
) |> Doc.toString ~width:80 |> print_endline
417264
417264
[@@live]
417265
+
417265
417266
let attach tbl loc comments =
417266
417267
match comments with
417267
417268
| [] -> ()
@@ -417953,6 +417954,12 @@ let rec walkStructure s t comments =
417953
417954
partitionLeadingTrailing comments longident.loc in
417954
417955
attach t.leading longident.loc leading;
417955
417956
attach t.trailing longident.loc trailing;
417957
+ | Pexp_let (
417958
+ _recFlag,
417959
+ valueBindings,
417960
+ {pexp_desc = Pexp_construct ({txt = Longident.Lident "()"}, None)}
417961
+ ) ->
417962
+ walkValueBindings valueBindings t comments
417956
417963
| Pexp_let (_recFlag, valueBindings, expr2) ->
417957
417964
let comments = visitListButContinueWithRemainingComments
417958
417965
~getLoc:(fun n ->
@@ -421778,7 +421785,7 @@ let printMultilineCommentContent txt =
421778
421785
Doc.text "*/";
421779
421786
]
421780
421787
421781
- let printTrailingComment (nodeLoc : Location.t) comment =
421788
+ let printTrailingComment (prevLoc: Location.t) ( nodeLoc : Location.t) comment =
421782
421789
let singleLine = Comment.isSingleLineComment comment in
421783
421790
let content =
421784
421791
let txt = Comment.txt comment in
@@ -421789,8 +421796,7 @@ let printTrailingComment (nodeLoc : Location.t) comment =
421789
421796
in
421790
421797
let diff =
421791
421798
let cmtStart = (Comment.loc comment).loc_start in
421792
- let prevTokEndPos = Comment.prevTokEndPos comment in
421793
- cmtStart.pos_lnum - prevTokEndPos.pos_lnum
421799
+ cmtStart.pos_lnum - prevLoc.loc_end.pos_lnum
421794
421800
in
421795
421801
let isBelow =
421796
421802
(Comment.loc comment).loc_start.pos_lnum > nodeLoc.loc_end.pos_lnum in
@@ -421912,12 +421918,12 @@ let printLeadingComments node tbl loc =
421912
421918
loop [] comments
421913
421919
421914
421920
let printTrailingComments node tbl loc =
421915
- let rec loop acc comments =
421921
+ let rec loop prev acc comments =
421916
421922
match comments with
421917
421923
| [] -> Doc.concat (List.rev acc)
421918
421924
| comment::comments ->
421919
- let cmtDoc = printTrailingComment loc comment in
421920
- loop (cmtDoc::acc) comments
421925
+ let cmtDoc = printTrailingComment prev loc comment in
421926
+ loop (Comment.loc comment) ( cmtDoc::acc) comments
421921
421927
in
421922
421928
match Hashtbl.find tbl loc with
421923
421929
| exception Not_found -> node
@@ -421926,7 +421932,7 @@ let printTrailingComments node tbl loc =
421926
421932
(* Remove comments from tbl: Some ast nodes have the same location.
421927
421933
* We only want to print comments once *)
421928
421934
Hashtbl.remove tbl loc;
421929
- let cmtsDoc = loop [] comments in
421935
+ let cmtsDoc = loop loc [] comments in
421930
421936
Doc.concat [
421931
421937
node;
421932
421938
cmtsDoc;
0 commit comments