Skip to content

Remove unused debugging aids - #8698

Merged
cknitt merged 4 commits into
masterfrom
cristianoc/remove-kept-debug-aids
Oct 4, 2026
Merged

cknitt merged 4 commits into
masterfrom
cristianoc/remove-kept-debug-aids

Conversation

@cristianoc

@cristianoc cristianoc commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #8712.

⚠️ @cknitt: please check before merging

These definitions were kept on purpose (marked [@@live]), but nothing in the repository uses them:

  • Scope.item_to_string (analysis)
  • Res_outcome_printer.parenthesized_ident (syntax)
  • Translate_structure.add_annotations_to_fields, and Translate_type_declarations.rename_record_field, whose only caller it was (genType)

Please confirm they can go; each is a separate commit, so any of them can be dropped.

Summary

  • Remove the unused Scope.item_to_string. Scope.item_to_string in analysis/src/scope.ml was kept only by its [@@LiVe] annotation. git grep over the whole repository (sources, tests, docs, scripts) finds no reference to Scope.item_to_string, no open or include of Scope that would expose it, and no other caller. The debug printing of scope items in completions.ml uses Shared_types.Scope_types.item_to_string, which stays.
  • Remove the unused Res_outcome_printer.parenthesized_ident. It was exported with [@@LiVe]; it always returned true and has no call site, inside the outcome printer or elsewhere, so no call site simplifies. Oprint.parenthesized_ident in compiler/ml is a separate function and stays.
  • Remove the unused Translate_structure.add_annotations_to_fields. add_annotations_to_fields was kept only by its [@@LiVe] annotation; its only caller was itself. git grep over the whole repository (sources, tests, docs, scripts) finds no other reference; the matches in tests/syntax_tests/data/idempotency/genType are ReScript copies of old sources used as parser input, not callers.
  • Add res_parser -print doc. It prints the document tree that Res_printer builds for a file, using Res_doc.debug, which stays. Res_printer exposes implementation_doc and interface_doc for it.

Test plan

  • dune build
  • dune build @fmt
  • dune build --profile browser @check
  • make
  • make lib
  • no change in the runtime and Belt lib/ outputs
  • make test
  • make test-analysis
  • make test-tools
  • make test-gentype
  • make test-syntax
  • make checkformat
  • npm run check

The -print doc commit was checked with dune build, dune build @fmt, and res_parser -print doc on a .res and a .resi file; the suites above ran before it.

🤖 Generated with Claude Code

@cristianoc
cristianoc requested a review from cknitt October 2, 2026 06:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 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-02T06:32:20.523488Z 9eb3c29 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.

@cristianoc cristianoc mentioned this pull request Oct 2, 2026
21 of 22 tasks
@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: f349d7f

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Comment thread compiler/syntax/src/res_printer.ml Outdated
cknitt
cknitt previously approved these changes Oct 2, 2026
process ~pos:0 [] [(0, Flat, doc)];
Mini_buffer.contents buffer

let debug t =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm maybe it would be good to keep actually, one might indeed need it for debug printing purposes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That requires making it actually used somewhere. Or else, it should go.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would only be used when adding debug printing temporarily while working on some printer issues.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it has to be integrated in a command line, rather than dead code

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add that to the PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8566df8: res_parser -print doc file.res prints the document tree with Res_doc.debug, which stays. Res_printer exposes implementation_doc and interface_doc for it, and the syntax README lists the command.

@cknitt
cknitt dismissed their stale review October 2, 2026 18:30

Maybe keep Res_doc.debug?

@cknitt

cknitt commented Oct 4, 2026

Copy link
Copy Markdown
Member

Could you resolve the conflicts?

cristianoc and others added 4 commits October 4, 2026 08:35
Scope.item_to_string in analysis/src/scope.ml was kept only by its
[@@LiVe] annotation. git grep over the whole repository (sources, tests,
docs, scripts) finds no reference to Scope.item_to_string, no open or
include of Scope that would expose it, and no other caller. The debug
printing of scope items in completions.ml uses
Shared_types.Scope_types.item_to_string, which stays.

To restore it, git revert this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
…_ident

Both were exported with [@@LiVe] and have no consumer:

- Res_doc.debug printed a document tree to stdout. Its only mention was
  the commented-out "(* Doc.debug doc; *)" in
  Res_printer.print_implementation, deleted here with it.
- Res_outcome_printer.parenthesized_ident always returned true and has no
  call site, inside the outcome printer or elsewhere, so no call site
  simplifies. Oprint.parenthesized_ident in compiler/ml is a separate
  function and stays.

git grep over the whole repository (sources, tests, docs, scripts) finds
no other reference; the matches in tests/syntax_benchmarks/data and
tests/syntax_tests/data/idempotency are ReScript copies of old sources
used as parser input, not callers.

To restore them, git revert this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
add_annotations_to_fields was kept only by its [@@LiVe] annotation; its
only caller was itself. git grep over the whole repository (sources,
tests, docs, scripts) finds no other reference; the matches in
tests/syntax_tests/data/idempotency/genType are ReScript copies of old
sources used as parser input, not callers.

Its removal leaves Translate_type_declarations.rename_record_field with
no caller, so that goes too. The comment on declared_field_name referred
to it, and now describes declared_field_name itself.

To restore them, git revert this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
Res_doc.debug stays and becomes the -print doc engine of res_parser,
which prints the document Res_printer builds for a file. Res_printer
exposes implementation_doc and interface_doc for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@cristianoc
cristianoc force-pushed the cristianoc/remove-kept-debug-aids branch from 8566df8 to f349d7f Compare October 4, 2026 07:36
@cknitt
cknitt enabled auto-merge (squash) October 4, 2026 07:43
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.88%. Comparing base (0507cec) to head (f349d7f).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
compiler/syntax/src/res_ast_debugger.ml 0.00% 2 Missing ⚠️
compiler/syntax/cli/res_cli.ml 0.00% 1 Missing ⚠️
compiler/syntax/src/res_doc.ml 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8698      +/-   ##
==========================================
+ Coverage   79.86%   79.88%   +0.01%     
==========================================
  Files         470      470              
  Lines       63443    63429      -14     
==========================================
+ Hits        50671    50672       +1     
+ Misses      12772    12757      -15     
Files with missing lines Coverage Δ
analysis/src/scope.ml 100.00% <ø> (+10.46%) ⬆️
compiler/gentype/translate_structure.ml 73.97% <ø> (+1.97%) ⬆️
compiler/gentype/translate_type_declarations.ml 89.51% <ø> (+2.43%) ⬆️
compiler/syntax/src/res_outcome_printer.ml 62.32% <ø> (+0.10%) ⬆️
compiler/syntax/src/res_printer.ml 93.48% <100.00%> (+<0.01%) ⬆️
compiler/syntax/cli/res_cli.ml 73.91% <0.00%> (-1.65%) ⬇️
compiler/syntax/src/res_doc.ml 68.61% <0.00%> (ø)
compiler/syntax/src/res_ast_debugger.ml 98.11% <0.00%> (-0.29%) ⬇️
🚀 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 merged commit a55e289 into master Oct 4, 2026
24 checks passed
@cknitt
cknitt deleted the cristianoc/remove-kept-debug-aids branch October 4, 2026 07:53
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