Fix unstable formatting of trailing callback comments - #8627
Conversation
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. |
There was a problem hiding this comment.
💡 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".
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8627 |
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
1b6fd4a to
faabd79
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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".
| (fun (_, (arg : Parsetree.expression)) -> | ||
| has_trailing_comments cmt_tbl arg.pexp_loc) |
There was a problem hiding this comment.
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>
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-syntaxmake test-syntax-roundtripdune exec syntax_testsmake checkformat