File tree 1 file changed +16
-6
lines changed
1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -4730,6 +4730,20 @@ and print_arguments ~state ?(partial = false)
4730
4730
in
4731
4731
Doc. concat [Doc. lparen; arg_doc; Doc. rparen]
4732
4732
| args ->
4733
+ (* Avoid printing trailing comma when there is ... in function application *)
4734
+ let hasDotDotDot, printed_args =
4735
+ List. fold_right
4736
+ (fun arg (flag , acc ) ->
4737
+ let arg_lbl, _ = arg in
4738
+ let hasDotDotDot =
4739
+ match arg_lbl with
4740
+ | Asttypes. Labelled "..." -> true
4741
+ | _ -> false
4742
+ in
4743
+ let doc = print_argument ~state arg cmt_tbl in
4744
+ (flag || hasDotDotDot, doc :: acc))
4745
+ args (false , [] )
4746
+ in
4733
4747
Doc. group
4734
4748
(Doc. concat
4735
4749
[
@@ -4738,13 +4752,9 @@ and print_arguments ~state ?(partial = false)
4738
4752
(Doc. concat
4739
4753
[
4740
4754
Doc. soft_line;
4741
- Doc. join
4742
- ~sep: (Doc. concat [Doc. comma; Doc. line])
4743
- (List. map
4744
- (fun arg -> print_argument ~state arg cmt_tbl)
4745
- args);
4755
+ Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) printed_args;
4746
4756
]);
4747
- (if partial then Doc. nil else Doc. trailing_comma);
4757
+ (if partial || hasDotDotDot then Doc. nil else Doc. trailing_comma);
4748
4758
Doc. soft_line;
4749
4759
Doc. rparen;
4750
4760
])
You can’t perform that action at this time.
0 commit comments