Skip to content

Fix unstable formatting of trailing callback comments - #8627

Open
cknitt wants to merge 4 commits into
masterfrom
codex/fix-callback-comment-formatting
Open

Fix unstable formatting of trailing callback comments#8627
cknitt wants to merge 4 commits into
masterfrom
codex/fix-callback-comment-formatting

Conversation

@cknitt

@cknitt cknitt commented Sep 4, 2026

Copy link
Copy Markdown
Member

Trailing comments in nested callbacks could move outward across successive formatting passes. Use the regular argument layout when arguments have trailing comments so formatting is stable after the first pass.

Add regression coverage for nested callbacks, first and last callback arguments, and line and block comments, including stability checks at five print widths.

Fixes #6976.

Validation:

  • make test-syntax
  • make test-syntax-roundtrip
  • dune exec syntax_tests
  • make checkformat

@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-06T05:09:02.456190Z faabd79 Manual request
ℹ️ 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.

@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: 3ca9d2eda3

ℹ️ 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 CHANGELOG.md Outdated
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.38%. Comparing base (5357fe4) to head (006bd20).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8627   +/-   ##
=======================================
  Coverage   77.38%   77.38%           
=======================================
  Files         474      474           
  Lines       63553    63553           
=======================================
  Hits        49178    49178           
  Misses      14375    14375           
Files with missing lines Coverage Δ
compiler/syntax/src/res_printer.ml 92.95% <100.00%> (ø)
🚀 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@8627

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 006bd20

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the codex/fix-callback-comment-formatting branch from 1b6fd4a to faabd79 Compare September 6, 2026 05:05
@cknitt

cknitt commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

@codex review

@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: faabd790b0

ℹ️ 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 Outdated
Comment on lines +4670 to +4671
(fun (_, (arg : Parsetree.expression)) ->
has_trailing_comments cmt_tbl arg.pexp_loc)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check the full labeled-argument location for comments

For labeled or optional callbacks, walk_apply_expr attaches a comment after the callback to the argument location spanning from the label through the expression, not to arg.pexp_loc. Consequently, inputs such as call(~fn=x => x /* keep */) leave args_have_trailing_comments false, select the compact callback path, and that path only prints comments associated with the expression location, so the comment can still move or be dropped. Build the same combined location used by ExprArgument when performing this check.

Useful? React with 👍 / 👎.

Signed-off-by: Christoph Knittel <ck@cca.io>
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.

Unstable formatting of comments

1 participant