Fix functor module type result-signature brace formatting#8519
Fix functor module type result-signature brace formatting#8519MavenRain wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 77aaf8f19b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| #### :bug: Bug fix | ||
|
|
||
| - Fix formatter breaking the opening brace of a functor module type's result signature onto a new line (e.g. `module Make: Pattern => {`). https://github.com/rescript-lang/rescript/pull/PLACEHOLDER_PR |
There was a problem hiding this comment.
Replace the placeholder PR link
If this changelog entry is merged as-is, the published changelog will contain a dead https://github.com/rescript-lang/rescript/pull/PLACEHOLDER_PR link instead of the actual PR reference required for user-facing changes.
AGENTS.md reference: AGENTS.md:L129-L129
Useful? React with 👍 / 👎.
Fix functor module type result-signature brace formatting
Fixes #7949.
Problem
When a functor module type returns a signature, the formatter broke the
opening brace onto its own line:
This is inconsistent with functor module expressions, which already keep the
brace on the same line as
=>:Cause
In
print_mod_type(thePmty_functorarm ofcompiler/syntax/src/res_printer.ml),the arrow was followed by a breakable
Doc.line. Because a signature resultforce-breaks internally, the enclosing group always broke at that
Doc.line,pushing
{to the next line. The siblingprint_mod_functor(moduleexpressions) uses an unconditional hard space (
Doc.text " => ") and so neverhad this problem.
Fix
When the functor result is a signature, use a hard space before it (hug the
brace); otherwise keep the breakable
Doc.lineso long non-signature results(idents,
withconstraints, curried arrows) can still wrap:Testing
tests/syntax_tests/data/printer/modType/functorInterface.resicovering the reported
.resicase plus curried params, a nested/curried arrow,an empty signature, and non-signature results (which must remain unchanged).
(
modType/functor.res.txtmodule type B = () => {, andmodExpr/structure.res.txtmodule G0: (X: {}) => {).make test-syntaxandmake test-syntax-roundtrippass; the printer +idempotency corpus round-trips with no diff, and comments around
=>/ insidethe result signature are preserved.
Drafted with AI assistance; the change, tests, and verification were reviewed by me.