Skip to content

ensure trailing comma is never printed after ... for partial application #6306

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

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jscomp/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4018,7 +4018,7 @@ and printPexpApply ~state expr cmtTbl =
argsDoc;
]
else
let argsDoc = printArguments ~state ~dotted args cmtTbl in
let argsDoc = printArguments ~state ~dotted ~partial args cmtTbl in
Doc.concat [printAttributes ~state attrs cmtTbl; callExprDoc; argsDoc]
| _ -> assert false

Expand Down Expand Up @@ -4524,7 +4524,7 @@ and printArgumentsWithCallbackInLastPosition ~state ~dotted args cmtTbl =
Lazy.force breakAllArgs;
]

and printArguments ~state ~dotted
and printArguments ~state ~dotted ?(partial = false)
(args : (Asttypes.arg_label * Parsetree.expression) list) cmtTbl =
match args with
| [
Expand Down Expand Up @@ -4564,7 +4564,7 @@ and printArguments ~state ~dotted
~sep:(Doc.concat [Doc.comma; Doc.line])
(List.map (fun arg -> printArgument ~state arg cmtTbl) args);
]);
Doc.trailingComma;
(if partial then Doc.nil else Doc.trailingComma);
Doc.softLine;
Doc.rparen;
])
Expand Down
17 changes: 17 additions & 0 deletions jscomp/syntax/tests/printer/expr/UncurriedByDefault.res
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,20 @@ let aU = (() => "foo")->Ok
Ok("_")->Belt.Result.map(concatStrings(_, "foo"))

let ptl1 = add(1, ...)

let fn = (
i,
~hello,
~moreGoesHere,
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
) => {
i + hello + moreGoesHere + provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
}

let partial =
fn(
~hello=1,
~moreGoesHere=1,
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=1,
...
)
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,23 @@ let aU = (() => "foo")->Ok
Ok("_")->Belt.Result.map(concatStrings(_, "foo"))

let ptl1 = add(1, ...)

let fn = (
i,
~hello,
~moreGoesHere,
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
) => {
i +
hello +
moreGoesHere +
provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
}

let partial =
fn(
~hello=1,
~moreGoesHere=1,
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=1,
...
)