Skip to content

Fix formatter removed parens from functor type #7735

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 4 commits into from
Jul 29, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#### :bug: Bug fix

- Fix error message that falsely suggested using coercion when it wouldn't work. https://github.com/rescript-lang/rescript/pull/7721
- Fix formatter removes () from functor type. https://github.com/rescript-lang/rescript/pull/7735

# 12.0.0-beta.3

Expand Down
10 changes: 8 additions & 2 deletions compiler/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ and print_mod_type ~state mod_type cmt_tbl =
Doc.concat [attrs; print_mod_type ~state mod_type cmt_tbl]
in
print_comments doc cmt_tbl cmt_loc
| [(attrs, {Location.txt = "*"; loc}, None)] ->
let attrs = print_attributes ~state attrs cmt_tbl in
let doc = Doc.concat [attrs; Doc.text "()"] in
print_comments doc cmt_tbl loc
| params ->
Doc.group
(Doc.concat
Expand Down Expand Up @@ -834,8 +838,10 @@ and print_mod_type ~state mod_type cmt_tbl =
print_attributes ~state attrs cmt_tbl
in
let lbl_doc =
if lbl.Location.txt = "_" || lbl.txt = "*" then
Doc.nil
if lbl.Location.txt = "_" then Doc.nil
else if lbl.txt = "*" then
let doc = Doc.text "()" in
print_comments doc cmt_tbl lbl.loc
else
let doc = Doc.text lbl.txt in
print_comments doc cmt_tbl lbl.loc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ module React = {

let render = () => Js.log("foo")
}

module Make: () => S = (_: Config, ()) => {}
module rec Make: (Config, ()) => S = (Config: Config, ()): S => {}
3 changes: 3 additions & 0 deletions tests/syntax_tests/data/printer/structure/moduleBinding.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ module React = {

let render = () => Js.log("foo")
}

module Make: () => S = (Config, ()) => {}
module rec Make: (Config, ()) => S = (Config: Config, ()): S => {}