Fix lost and unstable comments around callbacks - #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.58% 77.58%
=======================================
Files 475 475
Lines 64051 64062 +11
=======================================
+ Hits 49693 49704 +11
Misses 14358 14358
🚀 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".
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
Trailing comments in nested callbacks could move outward across successive formatting passes, and comments on labeled or optional callbacks could disappear. For example, formatting
call(~fn=x => x /* keep */)dropped the comment.Share the argument-span calculation between comment attachment and printing so both use the same location. An explicit fallback rule selects the regular argument layout for trailing comments and leading comments on labeled arguments, checking both the full argument and expression locations. Leading comments on unlabeled arguments retain the compact layout to preserve stability when parameter parentheses are removed. Force a line break for trailing callback line comments so they remain inside the argument list.
Share callback label printing and assemble the call document once while preserving the existing layout-specific break behavior.
Add regression coverage for labeled, optional, first, last, and nested callbacks with leading and trailing comments. The regression test checks comment text and order preservation as well as formatting stability at five print widths, reusing the parsed intermediate output.
Fixes #6976.
Validation:
make test-syntaxmake test-syntax-roundtripdune exec syntax_testsmake checkformatKnown limitation: a separate pre-existing layout instability remains at width 20 for a comment inside a braced callback body used as the first argument, such as
call(x => { /* comment */ x }, value), including labeled variants.