-
Notifications
You must be signed in to change notification settings - Fork 471
Skip trailing comma in explicit partial application #6949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4730,6 +4730,20 @@ and print_arguments ~state ?(partial = false) | |
| in | ||
| Doc.concat [Doc.lparen; arg_doc; Doc.rparen] | ||
| | args -> | ||
| (* Avoid printing trailing comma when there is ... in function application *) | ||
| let hasDotDotDot, printed_args = | ||
|
||
| List.fold_right | ||
| (fun arg (flag, acc) -> | ||
| let arg_lbl, _ = arg in | ||
| let hasDotDotDot = | ||
| match arg_lbl with | ||
| | Asttypes.Labelled "..." -> true | ||
| | _ -> false | ||
| in | ||
| let doc = print_argument ~state arg cmt_tbl in | ||
| (flag || hasDotDotDot, doc :: acc)) | ||
| args (false, []) | ||
| in | ||
| Doc.group | ||
| (Doc.concat | ||
| [ | ||
|
|
@@ -4738,13 +4752,9 @@ and print_arguments ~state ?(partial = false) | |
| (Doc.concat | ||
| [ | ||
| Doc.soft_line; | ||
| Doc.join | ||
| ~sep:(Doc.concat [Doc.comma; Doc.line]) | ||
| (List.map | ||
| (fun arg -> print_argument ~state arg cmt_tbl) | ||
| args); | ||
| Doc.join ~sep:(Doc.concat [Doc.comma; Doc.line]) printed_args; | ||
| ]); | ||
| (if partial then Doc.nil else Doc.trailing_comma); | ||
| (if partial || hasDotDotDot then Doc.nil else Doc.trailing_comma); | ||
| Doc.soft_line; | ||
| Doc.rparen; | ||
| ]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters whether to check if
...happens at the end because that's already considered as syntax error.