Repository navigation
Keep the header of a let with locally abstract types on one line - #9082
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page ✏️ Keep the header of a let with locally abstract types on one line3a28be2 · cknitt + Claude · Oct 27, 2026, 12:50 UTC · edited
Format modified (let with locally abstract types) let rec eval: type a. expr<a> => a = e =>
switch e {
| Int(n) => n
| Bool(b) => b
}
-let rec eval:
- type a. expr<a> => a =
- e =>
- switch e {
- | Int(n) => n
- | Bool(b) => b
- }
+let rec eval: type a. expr<a> => a = e =>
+ switch e {
+ | Int(n) => n
+ | Bool(b) => b
+ }Review
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ocaml-feature-tests #9082 +/- ##
====================================================
Coverage 81.69% 81.69%
====================================================
Files 460 460
Lines 64728 64733 +5
====================================================
+ Hits 52879 52884 +5
Misses 11849 11849
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
23146ca to
fe33a6f
Compare
Why:
A binding annotated with `type a.` was printed as one group, so a line
break in its body, such as a switch, broke the header after `:` and
`=` as well and indented the body twice. This is how every function
over a GADT is written. The header now stays on one line when its
first line fits, as for other annotated bindings.
Format modified (let with locally abstract types):
Example:
let rec eval: type a. expr<a> => a = e =>
switch e {
| Int(n) => n
| Bool(b) => b
}
Before (rescript):
let rec eval:
type a. expr<a> => a =
e =>
switch e {
| Int(n) => n
| Bool(b) => b
}
After (rescript):
let rec eval: type a. expr<a> => a = e =>
switch e {
| Int(n) => n
| Bool(b) => b
}
Review: What happens to a header that doesn't fit?
It is printed as before, broken after `:` and `=`; the printer
fixture keeps such a case, also with attributes in front, which stay
outside the layout choice so that the header's width is measured
from the `let`.
Fixes: #9070
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
fe33a6f to
3a28be2
Compare
cristianoc
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for the changes.
Fixes #9070. Stacked on #9076, whose new test files this reformats.
The formatter printed a binding annotated with
type a.as one group, so a multi-line body broke the header after:and=and indented the body twice. Now the header stays on one line when its first line fits:A header that doesn't fit is printed as before. The printer fixture
newtype.resgains cases for both, also with a doc comment and attribute in front.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gLMawVgtmiKy3TMBc3