@@ -4120,7 +4120,13 @@ and printPexpApply ~state expr cmtTbl =
4120
4120
let partial, attrs = ParsetreeViewer. processPartialAppAttribute attrs in
4121
4121
let args =
4122
4122
if partial then
4123
- let dummy = Ast_helper.Exp. constant (Ast_helper.Const. int 0 ) in
4123
+ let loc =
4124
+ {Asttypes. txt = " res.partial" ; Asttypes. loc = expr.pexp_loc}
4125
+ in
4126
+ let attr = (loc, Parsetree. PTyp (Ast_helper.Typ. any () )) in
4127
+ let dummy =
4128
+ Ast_helper.Exp. constant ~attrs: [attr] (Ast_helper.Const. int 0 )
4129
+ in
4124
4130
args @ [(Asttypes. Labelled " ..." , dummy)]
4125
4131
else args
4126
4132
in
@@ -4700,6 +4706,18 @@ and printArguments ~state ~dotted ?(partial = false)
4700
4706
Doc. concat
4701
4707
[(if dotted then Doc. text " (. " else Doc. lparen); argDoc; Doc. rparen]
4702
4708
| args ->
4709
+ (* Avoid printing trailing comma when there is ... in function application *)
4710
+ let hasPartialAttr, printedArgs =
4711
+ List. fold_right
4712
+ (fun arg (flag , acc ) ->
4713
+ let _, expr = arg in
4714
+ let hasPartialAttr =
4715
+ ParsetreeViewer. hasPartialAttribute expr.Parsetree. pexp_attributes
4716
+ in
4717
+ let doc = printArgument ~state arg cmtTbl in
4718
+ (flag || hasPartialAttr, doc :: acc))
4719
+ args (false , [] )
4720
+ in
4703
4721
Doc. group
4704
4722
(Doc. concat
4705
4723
[
@@ -4708,11 +4726,9 @@ and printArguments ~state ~dotted ?(partial = false)
4708
4726
(Doc. concat
4709
4727
[
4710
4728
(if dotted then Doc. line else Doc. softLine);
4711
- Doc. join
4712
- ~sep: (Doc. concat [Doc. comma; Doc. line])
4713
- (List. map (fun arg -> printArgument ~state arg cmtTbl) args);
4729
+ Doc. join ~sep: (Doc. concat [Doc. comma; Doc. line]) printedArgs;
4714
4730
]);
4715
- (if partial then Doc. nil else Doc. trailingComma);
4731
+ (if partial || hasPartialAttr then Doc. nil else Doc. trailingComma);
4716
4732
Doc. softLine;
4717
4733
Doc. rparen;
4718
4734
])
0 commit comments