@@ -4146,7 +4146,13 @@ and print_pexp_apply ~state expr cmt_tbl =
4146
4146
let partial, attrs = ParsetreeViewer. process_partial_app_attribute attrs in
4147
4147
let args =
4148
4148
if partial then
4149
- let dummy = Ast_helper.Exp. constant (Ast_helper.Const. int 0 ) in
4149
+ let loc =
4150
+ {Asttypes. txt = " res.partial" ; Asttypes. loc = expr.pexp_loc}
4151
+ in
4152
+ let attr = (loc, Parsetree. PTyp (Ast_helper.Typ. any () )) in
4153
+ let dummy =
4154
+ Ast_helper.Exp. constant ~attrs: [attr] (Ast_helper.Const. int 0 )
4155
+ in
4150
4156
args @ [(Asttypes. Labelled " ..." , dummy)]
4151
4157
else args
4152
4158
in
@@ -4730,6 +4736,18 @@ and print_arguments ~state ?(partial = false)
4730
4736
in
4731
4737
Doc. concat [Doc. lparen; arg_doc; Doc. rparen]
4732
4738
| args ->
4739
+ (* Avoid printing trailing comma when there is ... in function application *)
4740
+ let has_partial_attr, printed_args =
4741
+ List. fold_right
4742
+ (fun arg (flag , acc ) ->
4743
+ let _, expr = arg in
4744
+ let has_partial_attr =
4745
+ ParsetreeViewer. has_partial_attribute expr.Parsetree. pexp_attributes
4746
+ in
4747
+ let doc = print_argument ~state arg cmt_tbl in
4748
+ (flag || has_partial_attr, doc :: acc))
4749
+ args (false , [] )
4750
+ in
4733
4751
Doc. group
4734
4752
(Doc. concat
4735
4753
[
@@ -4738,13 +4756,9 @@ and print_arguments ~state ?(partial = false)
4738
4756
(Doc. concat
4739
4757
[
4740
4758
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);
4759
+ Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) printed_args;
4746
4760
]);
4747
- (if partial then Doc. nil else Doc. trailing_comma);
4761
+ (if partial || has_partial_attr then Doc. nil else Doc. trailing_comma);
4748
4762
Doc. soft_line;
4749
4763
Doc. rparen;
4750
4764
])
0 commit comments