Skip to content

Remove dead internal compiler code - #8731

Merged
cknitt merged 2 commits into
masterfrom
remove-dead-internal-code
Oct 7, 2026
Merged

cknitt merged 2 commits into
masterfrom
remove-dead-internal-code

Conversation

@cknitt

@cknitt cknitt commented Oct 6, 2026

Copy link
Copy Markdown
Member

Motivation

A sweep for obsolete code turned up compiler internals that nothing produces or reads anymore, mostly OCaml-era leftovers. This PR removes the ones that are provably dead and have no user-visible effect. Larger, user-facing removals (deprecated Stdlib/Belt APIs, obsolete FFI attributes) are left for separate PRs.

What's removed

  • Warning 24 (Bad_module_name): declared, numbered and documented, but never raised. As with the earlier dead warnings (Remove dead and unreachable error and warning variants #8459), the number stays unused and is noted in tests/ERROR_VARIANTS.md.
  • J.String_index: a JS IR node that is never constructed. Its printer, analyzer and visitor cases go with it, along with the codePointAt literal only it used.
  • Pisint and Parraysets Lambda primitives: their only producers were the %obj_is_int and %array_safe_set primitive names, which nothing uses. Also removed: their codegen, the Pisint simplification in Lambda.if_, E.is_type_number, and the runtime Primitive_array.set, whose only caller was the Parraysets codegen.
  • Unused primitive names %obj_dup, %obj_field (already marked "FIXME: Deprecated"), %null_to_opt and %nullable_to_opt (duplicates of the internal # forms). Other unused names that belong to otherwise-used families (typed comparisons, BigInt ops) are kept on purpose.
  • Unread Clflags fields: fast, preprocessor, editor_mode, and applicative_functors (always true). The -pp flag, which only set preprocessor, is removed. -unsafe only set fast, but it stays accepted as an explicit no-op so existing compiler-flags keep working. It is dropped from the runtime and belt configs.
  • The unit slot of Pexp_coerce: an OCaml leftover ((e : t1 :> t2)) that was always (). Removed from the current parsetree only; the frozen parsetree0.ml and the v0 mapping keep the PPX wire format unchanged.

Testing

make test and make test-syntax pass, including the ast-mapping round-trip tests. No compiled JS output in the test suites changed.

🤖 Generated with Claude Code

cknitt and others added 2 commits October 6, 2026 20:12
- Warning 24 (Bad_module_name), which is never raised.
- The J.String_index JS IR node, which is never constructed.
- The Pisint and Parraysets Lambda primitives, their only producers
  (%obj_is_int, %array_safe_set), and Primitive_array.set and
  E.is_type_number, which only they used.
- The unused %obj_dup, %obj_field, %null_to_opt and %nullable_to_opt
  primitive names.
- The unread Clflags fields fast, preprocessor, editor_mode and
  applicative_functors, and the -pp flag. -unsafe stays accepted as a
  no-op and is dropped from the runtime and belt configs.
- The unit slot of Pexp_coerce in the current parsetree. The frozen
  v0 parsetree keeps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.91%. Comparing base (30ce369) to head (553a254).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
compiler/core/js_dump.ml 0.00% 3 Missing ⚠️
compiler/ml/lambda.ml 33.33% 2 Missing ⚠️
compiler/ml/typecore.ml 33.33% 2 Missing ⚠️
compiler/ml/ast_mapper_to0.ml 0.00% 1 Missing ⚠️
compiler/ml/printast.ml 0.00% 1 Missing ⚠️
tools/src/migrate.ml 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8731      +/-   ##
==========================================
+ Coverage   79.86%   79.91%   +0.05%     
==========================================
  Files         467      467              
  Lines       63357    63313      -44     
==========================================
- Hits        50600    50597       -3     
+ Misses      12757    12716      -41     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_main.ml 71.35% <ø> (-0.28%) ⬇️
compiler/core/j.ml 100.00% <ø> (ø)
compiler/core/js_analyzer.ml 83.33% <100.00%> (+2.00%) ⬆️
compiler/core/js_dump_lit.ml 100.00% <ø> (ø)
compiler/core/js_exp_make.ml 65.64% <ø> (+0.09%) ⬆️
compiler/core/js_record_fold.ml 92.85% <ø> (+1.77%) ⬆️
compiler/core/js_record_iter.ml 100.00% <ø> (+1.85%) ⬆️
compiler/core/js_record_map.ml 100.00% <ø> (+1.86%) ⬆️
compiler/core/lam_analysis.ml 68.14% <100.00%> (+1.48%) ⬆️
compiler/core/lam_compile_primitive.ml 78.73% <ø> (+0.51%) ⬆️
... and 20 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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 553a254

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

@cknitt
cknitt requested a review from cristianoc October 7, 2026 04:52
@cknitt
cknitt marked this pull request as ready for review October 7, 2026 04:52
@cknitt
cknitt merged commit b15ccd1 into master Oct 7, 2026
35 of 36 checks passed
@cknitt
cknitt deleted the remove-dead-internal-code branch October 7, 2026 06:37
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