@@ -4120,7 +4120,13 @@ and printPexpApply ~state expr cmtTbl =
41204120let partial, attrs= ParsetreeViewer. processPartialAppAttribute attrsin
41214121let args=
41224122if partialthen
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
41244130 args@ [(Asttypes. Labelled " ..." , dummy)]
41254131else args
41264132in
@@ -4700,6 +4706,18 @@ and printArguments ~state ~dotted ?(partial = false)
47004706Doc. concat
47014707 [(if dottedthen Doc. text" (." else Doc. lparen); argDoc;Doc. rparen]
47024708| 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= argin
4714+ let hasPartialAttr=
4715+ ParsetreeViewer. hasPartialAttribute expr.Parsetree. pexp_attributes
4716+ in
4717+ let doc= printArgument~state arg cmtTblin
4718+ (flag|| hasPartialAttr, doc :: acc))
4719+ args (false ,[] )
4720+ in
47034721Doc. group
47044722 (Doc. concat
47054723 [
@@ -4708,11 +4726,9 @@ and printArguments ~state ~dotted ?(partial = false)
47084726 (Doc. concat
47094727 [
47104728 (if dottedthen Doc. lineelse 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;
47144730 ]);
4715- (if partialthen Doc. nilelse Doc. trailingComma);
4731+ (if partial|| hasPartialAttr then Doc. nilelse Doc. trailingComma);
47164732Doc. softLine;
47174733Doc. rparen;
47184734 ])