@@ -692,9 +692,11 @@ and walkTypeDeclaration (td : Parsetree.type_declaration) t comments =
692692 | Ptype_abstract | Ptype_open -> rest
693693 | Ptype_record labelDeclarations ->
694694 let () =
695- walkList
696- (labelDeclarations |> List. map (fun ld -> LabelDeclaration ld))
697- t rest
695+ if labelDeclarations = [] then attach t.inside td.ptype_loc rest
696+ else
697+ walkList
698+ (labelDeclarations |> List. map (fun ld -> LabelDeclaration ld))
699+ t rest
698700 in
699701 []
700702 | Ptype_variant constructorDeclarations ->
@@ -1023,22 +1025,26 @@ and walkExpression expr t comments =
10231025 | Pexp_array exprs | Pexp_tuple exprs ->
10241026 walkList (exprs |> List. map (fun e -> Expression e)) t comments
10251027 | Pexp_record (rows , spreadExpr ) ->
1026- let comments =
1027- match spreadExpr with
1028- | None -> comments
1029- | Some expr ->
1030- let leading, inside, trailing = partitionByLoc comments expr.pexp_loc in
1031- attach t.leading expr.pexp_loc leading;
1032- walkExpression expr t inside;
1033- let afterExpr, rest =
1034- partitionAdjacentTrailing expr.pexp_loc trailing
1035- in
1036- attach t.trailing expr.pexp_loc afterExpr;
1037- rest
1038- in
1039- walkList
1040- (rows |> List. map (fun (li , e ) -> ExprRecordRow (li, e)))
1041- t comments
1028+ if rows = [] then attach t.inside expr.pexp_loc comments
1029+ else
1030+ let comments =
1031+ match spreadExpr with
1032+ | None -> comments
1033+ | Some expr ->
1034+ let leading, inside, trailing =
1035+ partitionByLoc comments expr.pexp_loc
1036+ in
1037+ attach t.leading expr.pexp_loc leading;
1038+ walkExpression expr t inside;
1039+ let afterExpr, rest =
1040+ partitionAdjacentTrailing expr.pexp_loc trailing
1041+ in
1042+ attach t.trailing expr.pexp_loc afterExpr;
1043+ rest
1044+ in
1045+ walkList
1046+ (rows |> List. map (fun (li , e ) -> ExprRecordRow (li, e)))
1047+ t comments
10421048 | Pexp_field (expr , longident ) ->
10431049 let leading, inside, trailing = partitionByLoc comments expr.pexp_loc in
10441050 let trailing =
0 commit comments