Skip to content

Represent ternary expressions with a dedicated parsetree node - #8674

Open
cknitt wants to merge 3 commits into
masterfrom
codex/ternary-parsetree-node
Open

cknitt wants to merge 3 commits into
masterfrom
codex/ternary-parsetree-node

Conversation

@cknitt

@cknitt cknitt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Refs #8624

Summary

  • Add Pexp_ternary with three required operands, so a ternary cannot lack an else branch.
  • Keep the existing res.ternary encoding only in the v0 PPX compatibility bridge.
  • Update typing, printing, AST consumers, and syntax snapshots. Preserve parentheses when a ternary is another ternary's condition.
  • Add bridge tests for round trips, attribute order, and incomplete legacy if nodes.

Signed-off-by: Christoph Knittel <ck@cca.io>
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the codex/ternary-parsetree-node branch from 7f5fa13 to 86f0ba9 Compare September 25, 2026 18:35
@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.51938% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.57%. Comparing base (5b00bcf) to head (8e699aa).

Files with missing lines Patch % Lines
compiler/syntax/src/res_parsetree_viewer.ml 36.36% 7 Missing ⚠️
compiler/ml/typecore.ml 37.50% 5 Missing ⚠️
compiler/ml/printast.ml 0.00% 4 Missing ⚠️
compiler/syntax/src/res_parens.ml 50.00% 4 Missing ⚠️
tests/ounit_tests/ounit_ast_mapper0_tests.ml 90.00% 4 Missing ⚠️
analysis/src/hint.ml 33.33% 2 Missing ⚠️
analysis/src/utils.ml 0.00% 1 Missing ⚠️
compiler/syntax/src/res_comments_table.ml 80.00% 1 Missing ⚠️
compiler/syntax/src/res_printer.ml 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8674   +/-   ##
=======================================
  Coverage   78.57%   78.57%           
=======================================
  Files         476      476           
  Lines       64157    64232   +75     
=======================================
+ Hits        50413    50472   +59     
- Misses      13744    13760   +16     
Files with missing lines Coverage Δ
analysis/src/xform.ml 88.35% <100.00%> (+0.08%) ⬆️
compiler/frontend/bs_builtin_ppx.ml 91.37% <100.00%> (+0.05%) ⬆️
compiler/ml/ast_helper.ml 80.79% <100.00%> (+0.06%) ⬆️
compiler/ml/ast_iterator.ml 93.89% <100.00%> (+0.05%) ⬆️
compiler/ml/ast_mapper.ml 77.58% <100.00%> (+0.09%) ⬆️
compiler/ml/ast_mapper_from0.ml 72.26% <100.00%> (+0.40%) ⬆️
compiler/ml/ast_mapper_to0.ml 71.48% <100.00%> (+0.28%) ⬆️
compiler/ml/depend.ml 83.38% <100.00%> (+0.15%) ⬆️
compiler/ml/pprintast.ml 91.33% <100.00%> (+0.03%) ⬆️
compiler/syntax/src/res_ast_debugger.ml 96.22% <100.00%> (+0.03%) ⬆️
... and 10 more
🚀 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.

@cknitt
cknitt marked this pull request as ready for review September 25, 2026 19:05

@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: 86f0ba9278

ℹ️ 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_comments_table.ml
Comment thread compiler/ml/pprintast.ml Outdated
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt

cknitt commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8e699aa5f7

ℹ️ 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".

@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8674

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8674

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8674

@rescript/win32-x64

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

commit: 8e699aa

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt requested a review from cristianoc September 25, 2026 20:20

This branch has not been deployed

No deployments
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.

1 participant