Skip to content

Print coercions with context-aware parentheses - #8614

Open
cknitt wants to merge 3 commits into
masterfrom
codex/coercion-parentheses
Open

Print coercions with context-aware parentheses#8614
cknitt wants to merge 3 commits into
masterfrom
codex/coercion-parentheses

Conversation

@cknitt

@cknitt cknitt commented Sep 4, 2026

Copy link
Copy Markdown
Member

The formatter currently turns foo(v :> b) into foo((v :> b)). Reuse the existing parentheses rules to omit unnecessary parentheses in calls, collections, and array indices while preserving grouping where required.

Keep parentheses for binding right-hand sides, arrow bodies, operators, field access, block sequences, constrained operands, and attributes. Bindings remain parenthesized because a following JSX element can otherwise be parsed as coercion type arguments. The parser is unchanged.

Add regression coverage for constrained operands and bindings followed by JSX, and reformat existing sources affected by the new rules.

Validation: make test, make checkformat, make test-syntax, and make test-syntax-roundtrip, plus structure-preservation and formatting-stability checks at widths 20, 80, and 100.

Fixes #6254.

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-04T11:30:21.476807Z 00d09b5 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: 00d09b5a27

ℹ️ 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_parens.ml Outdated
Signed-off-by: Christoph Knittel <ck@cca.io>
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.43478% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.33%. Comparing base (56fe3bc) to head (df3784c).

Files with missing lines Patch % Lines
compiler/syntax/src/res_parens.ml 52.63% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8614   +/-   ##
=======================================
  Coverage   77.32%   77.33%           
=======================================
  Files         467      467           
  Lines       63313    63322    +9     
=======================================
+ Hits        48957    48969   +12     
+ Misses      14356    14353    -3     
Files with missing lines Coverage Δ
compiler/syntax/src/res_printer.ml 93.07% <100.00%> (+0.12%) ⬆️
compiler/syntax/src/res_parens.ml 85.27% <52.63%> (+0.11%) ⬆️
🚀 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@8614

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: df3784c

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

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.

Print :> without wrapping parenthesis

1 participant