Skip to content

Fix function assignment formatting and unify formatter paths - #8611

Merged
cknitt merged 8 commits into
masterfrom
codex/fix-function-assignment-formatting
Sep 4, 2026
Merged

Fix function assignment formatting and unify formatter paths#8611
cknitt merged 8 commits into
masterfrom
codex/fix-function-assignment-formatting

Conversation

@cknitt

@cknitt cknitt commented Sep 4, 2026

Copy link
Copy Markdown
Member

Fixes #8049.

Function assignments using := now avoid unnecessary parentheses and indentation, and attributes stay beside function parameters.

Share assignment layout across refs, record fields, and object fields, fixing excess indentation for records and arrays while preserving explicit braces. Consolidate standalone and callback function printing so callbacks retain function return-type parentheses and format JSX fragments consistently. Remove obsolete helpers and unused parameters.

Validation:

  • Syntax and round-trip suites pass.
  • New regression fixtures preserve their AST and format consistently at widths 40, 80, and 120.
  • Existing snapshots remain unchanged.
  • OCaml formatting checks pass.

Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T05:39:11.491271Z 05d61c7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Signed-off-by: Christoph Knittel <ck@cca.io>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05d61c73ed

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compiler/syntax/src/res_printer.ml
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.32%. Comparing base (bc382a4) to head (b7dc86c).

Files with missing lines Patch % Lines
compiler/syntax/src/res_printer.ml 95.65% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8611      +/-   ##
==========================================
- Coverage   77.32%   77.32%   -0.01%     
==========================================
  Files         467      467              
  Lines       63342    63313      -29     
==========================================
- Hits        48982    48957      -25     
+ Misses      14360    14356       -4     
Files with missing lines Coverage Δ
compiler/syntax/src/res_parens.ml 85.15% <ø> (+0.36%) ⬆️
compiler/syntax/src/res_parsetree_viewer.ml 91.30% <100.00%> (-0.03%) ⬇️
compiler/syntax/src/res_printer.ml 92.95% <95.65%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@8611

@rescript/belt

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/belt@8611

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@8611

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@8611

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@8611

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@8611

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@8611

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@8611

commit: b7dc86c

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

@fhammerschmidt fhammerschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely!

let make =
@directive("'use memo'")
(~count, ~username=?) => {
@directive("'use memo'") (~count, ~username=?) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this.

asyncIterableForAwaitLoopControlValues := [
...asyncIterableForAwaitLoopControlValues.contents,
value,
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is arguably more readable, but it also indicates this PR will possibly yield lots of changes in production codebases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't see a single one in one of our quite large codebases.
And I think the unification is worth it!

223 * accu.contents + String.codePointAt(s, i)->Option.getUnsafe,
Int.shiftLeft(1, 31) - 1,
)
accu := Int.bitwiseAnd(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!

@cknitt
cknitt merged commit 56fe3bc into master Sep 4, 2026
29 checks passed
@cknitt
cknitt deleted the codex/fix-function-assignment-formatting branch September 4, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird formatting when assigning function to ref

2 participants