Skip to content

Remove the unused restoring of the PPX context - #8859

Merged
cknitt merged 1 commit into
masterfrom
remove-ppx-context-restore
Oct 14, 2026
Merged

cknitt merged 1 commit into
masterfrom
remove-ppx-context-restore

Conversation

@cknitt

@cknitt cknitt commented Oct 13, 2026

Copy link
Copy Markdown
Member

The compiler sends every external PPX an [@@@ocaml.ppx.context] attribute and drops it again from the PPX's output. Ast_mapper.drop_ppx_context_str/_sig could also restore the context's data in the compiler (include dirs, load path, open modules, debug and cookies), but all four callers pass ~restore:false. So Ppx_context.restore never ran and the cookie store stayed empty: PPXs always got cookies = [], and cookies they set were discarded.

This removes the dead code: Ppx_context.restore, the cookie store and the ~restore parameter of Cmd_ppx_apply.apply_rewriters and Ast_mapper.drop_ppx_context_*. The context PPXs receive is unchanged; it still carries an empty cookies field, and its strings still go through the v0 mapper as plain semantic strings.

Found while making compiler state per-request for in-process compilation (#8781), where the cookie store was one of the globals to isolate.

Tests

tests/ounit_tests/ounit_ast_mapper0_tests.ml pins the v0 context a PPX receives: its field names, and an empty cookies list.

🤖 Generated with Claude Code

@cknitt
cknitt force-pushed the remove-ppx-context-restore branch from c23eb5e to debb3cc Compare October 13, 2026 14:56
@cknitt
cknitt marked this pull request as ready for review October 13, 2026 14:56
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.51%. Comparing base (52783c8) to head (25266eb).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
tests/ounit_tests/ounit_ast_mapper0_tests.ml 88.23% 2 Missing ⚠️
compiler/core/cmd_ppx_apply.ml 75.00% 1 Missing ⚠️
compiler/ml/ast_mapper.ml 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8859      +/-   ##
==========================================
+ Coverage   80.49%   80.51%   +0.02%     
==========================================
  Files         447      447              
  Lines       61027    61060      +33     
==========================================
+ Hits        49123    49162      +39     
+ Misses      11904    11898       -6     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_main.ml 71.35% <ø> (ø)
compiler/core/js_implementation.ml 84.76% <100.00%> (ø)
compiler/core/cmd_ppx_apply.ml 80.00% <75.00%> (+2.80%) ⬆️
compiler/ml/ast_mapper.ml 98.64% <66.66%> (+8.22%) ⬆️
tests/ounit_tests/ounit_ast_mapper0_tests.ml 90.98% <88.23%> (-0.05%) ⬇️

... and 6 files with indirect coverage changes

🚀 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 commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-10-13T15:23:48.051144Z debb3cc 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: debb3ccbb5

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

@cknitt
cknitt requested a review from cristianoc October 13, 2026 15:28
@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 25266eb

@github-actions

Copy link
Copy Markdown

@cknitt
cknitt requested a review from fhammerschmidt October 14, 2026 08:11
Every caller drops the context without restoring it, so the cookie store was never filled. PPXs still receive an empty cookies field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WZbCuRQ1Tn31bnKzLj5e72
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the remove-ppx-context-restore branch from debb3cc to 25266eb Compare October 14, 2026 08:44
@cknitt
cknitt enabled auto-merge (squash) October 14, 2026 08:47
@cknitt
cknitt merged commit 50a4103 into master Oct 14, 2026
26 checks passed
@cknitt
cknitt deleted the remove-ppx-context-restore branch October 14, 2026 09:03
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.

2 participants