@@ -90,7 +90,7 @@ let printMultilineCommentContent txt =
9090 Doc. text " */" 
9191 ]
9292
93- let  printTrailingComment  (nodeLoc  : Location.t ) comment  = 
93+ let  printTrailingComment  (prevLoc : Location.t ) ( nodeLoc  : Location.t ) comment  = 
9494 let  singleLine =  Comment. isSingleLineComment comment in 
9595 let  content = 
9696 let  txt =  Comment. txt comment in 
@@ -101,8 +101,7 @@ let printTrailingComment (nodeLoc : Location.t) comment =
101101 in 
102102 let  diff = 
103103 let  cmtStart =  (Comment. loc comment).loc_start in 
104-  let  prevTokEndPos =  Comment. prevTokEndPos comment in 
105-  cmtStart.pos_lnum -  prevTokEndPos.pos_lnum
104+  cmtStart.pos_lnum -  prevLoc.loc_end.pos_lnum
106105 in 
107106 let  isBelow = 
108107 (Comment. loc comment).loc_start.pos_lnum >  nodeLoc.loc_end.pos_lnum in 
@@ -224,12 +223,12 @@ let printLeadingComments node tbl loc =
224223 loop []  comments
225224
226225let  printTrailingComments  node  tbl  loc  = 
227-  let  rec  loop  acc  comments  = 
226+  let  rec  loop  prev   acc  comments  = 
228227 match  comments with 
229228 |  []  -> Doc. concat (List. rev acc)
230229 |  comment ::comments  ->
231-  let  cmtDoc =  printTrailingComment loc comment in 
232-  loop (cmtDoc::acc) comments
230+  let  cmtDoc =  printTrailingComment prev  loc comment in 
231+  loop (Comment. loc comment) ( cmtDoc::acc) comments
233232 in 
234233 match  Hashtbl. find tbl loc with 
235234 |  exception  Not_found  -> node
@@ -238,7 +237,7 @@ let printTrailingComments node tbl loc =
238237 (*  Remove comments from tbl: Some ast nodes have the same location.
239238 * We only want to print comments once *)  
240239 Hashtbl. remove tbl loc;
241-  let  cmtsDoc =  loop []  comments in 
240+  let  cmtsDoc =  loop loc  []  comments in 
242241 Doc. concat [
243242 node;
244243 cmtsDoc;
0 commit comments