@@ -692,9 +692,11 @@ and walkTypeDeclaration (td : Parsetree.type_declaration) t comments =
692
692
| Ptype_abstract | Ptype_open -> rest
693
693
| Ptype_record labelDeclarations ->
694
694
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
698
700
in
699
701
[]
700
702
| Ptype_variant constructorDeclarations ->
@@ -1023,22 +1025,26 @@ and walkExpression expr t comments =
1023
1025
| Pexp_array exprs | Pexp_tuple exprs ->
1024
1026
walkList (exprs |> List. map (fun e -> Expression e)) t comments
1025
1027
| 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
1042
1048
| Pexp_field (expr , longident ) ->
1043
1049
let leading, inside, trailing = partitionByLoc comments expr.pexp_loc in
1044
1050
let trailing =
0 commit comments