Skip to content

Fix formatter eats comments on the first argument of a uncurried function #6763

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 3 commits into from
May 23, 2024
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
3 changes: 3 additions & 0 deletions jscomp/syntax/src/res_comments_table.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,9 @@ and walkCoreType typ t comments =
attach t.trailing typexpr.ptyp_loc afterTyp
| Ptyp_variant (rowFields, _, _) ->
walkList (rowFields |> List.map (fun rf -> RowField rf)) t comments
| Ptyp_constr
({txt = Lident "function$"}, [({ptyp_desc = Ptyp_arrow _} as desc); _]) ->
walkCoreType desc t comments
| Ptyp_constr (longident, typexprs) ->
let beforeLongident, _afterLongident =
partitionLeadingTrailing comments longident.loc
Expand Down
14 changes: 14 additions & 0 deletions jscomp/syntax/tests/printer/comments/expected/typexpr.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,17 @@ type jsUser = /* before */ {
// above age
/* before age */ "age" /* after age */: /* before int */ int /* after int */,
} /* after */

external test: (
// comment 1
~int: int,
// comment 2
~int: int,
) => unit = "test"

external another_test: (
// comment 1
int,
// comment 2
int,
) => unit = "test"
14 changes: 14 additions & 0 deletions jscomp/syntax/tests/printer/comments/typexpr.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ type jsUser = /* before */ {
// above age
/* before age */"age" /* after age */: /*before int */ int /*after int */
} /* after */

external test: (
// comment 1
~int: int,
// comment 2
~int: int,
) => unit = "test"

external another_test: (
// comment 1
int,
// comment 2
int,
) => unit = "test"
Loading