Skip to content

Remove dead code enabled by structural arity - #8569

Open
cristianoc wants to merge 1 commit into
codex/nary-typed-layersfrom
codex/nary-dead-code
Open

Remove dead code enabled by structural arity#8569
cristianoc wants to merge 1 commit into
codex/nary-typed-layersfrom
codex/nary-dead-code

Conversation

@cristianoc

@cristianoc cristianoc commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Part of the n-ary functions series tracked in #8557 (item 6; stacked on #8568 via base branch only — each PR merges independently).

What

Dead-code removal enabled by structural arity, plus one module deletion:

  • The Too_many_arguments error cannot be raised anymore: the expected type is committed to an arrow of the literal's shape before destructuring, so every legacy path now surfaces as a regular type clash or Uncurried_arity_mismatch (which is what the fixture credited to it in ERROR_VARIANTS.md was already producing). Remove the variant, its printer, and the ?in_function threading through type_expect/type_cases that existed only to decorate it.
  • Remove the function$-vs-arrow unification bridge in ctype (nothing produces a function$ type expression anymore) — and the bridge matched by ident name only, so a user-defined type \"function$" (escaped identifiers make this expressible) would have received its unsound cast rule; removing it closes that hazard, the structural arity counter Ctype.arity (no callers), the parsetree arity probes get_uncurry_arity/get_curry_arity (is_arity_one reads the params list directly), and Ast_async's redundant newtype double-dig.
  • Deduplicate the arrow-flattening step shared by the analysis extract_function_type helpers.
  • Delete Ast_compatible outright. Every member was a thin veneer over an existing Ast_helper constructor (rec_type_str/rec_type_sig had byte-identical signatures to Str.type_/Sig.type_), hand-rolling the records the canonical constructors build; the OCaml-version compatibility it existed for is long gone, and its fun_ silently hard-coded arity 1. Call sites use Ast_helper directly, with two let-bound app1/app2 shorthands kept local to ast_derive_js_mapper.

Generated code is unchanged. The Pjs_fn_make no-op elision explored alongside these cleanups is deliberately left out: it lands as the dedicated analysis in #8570 (item 7).

🤖 Generated with Claude Code

@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: 75b5bee8ce

ℹ️ 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 CHANGELOG.md Outdated
@cristianoc
cristianoc force-pushed the codex/nary-dead-code branch from 7571858 to ddb086e Compare August 20, 2026 07:24
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.82%. Comparing base (63409eb) to head (2423f75).

Files with missing lines Patch % Lines
compiler/frontend/ast_core_type.ml 50.00% 1 Missing ⚠️
compiler/ml/typecore.ml 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           codex/nary-typed-layers    #8569      +/-   ##
===========================================================
+ Coverage                    75.81%   75.82%   +0.01%     
===========================================================
  Files                          475      474       -1     
  Lines                        62900    62870      -30     
===========================================================
- Hits                         47686    47671      -15     
+ Misses                       15214    15199      -15     
Files with missing lines Coverage Δ
analysis/src/type_utils.ml 63.99% <100.00%> (-0.05%) ⬇️
compiler/frontend/ast_comb.ml 100.00% <ø> (ø)
compiler/frontend/ast_core_type_class_type.ml 74.41% <100.00%> (ø)
compiler/frontend/ast_derive_abstract.ml 92.85% <100.00%> (ø)
compiler/frontend/ast_derive_js_mapper.ml 84.78% <100.00%> (+0.33%) ⬆️
compiler/frontend/ast_derive_projector.ml 90.62% <100.00%> (+0.14%) ⬆️
compiler/frontend/ast_exp_apply.ml 79.66% <100.00%> (ø)
compiler/frontend/ast_external_mk.ml 100.00% <100.00%> (ø)
compiler/frontend/ast_tdcls.ml 100.00% <100.00%> (ø)
compiler/ml/ast_async.ml 82.35% <100.00%> (-3.37%) ⬇️
... and 4 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 Aug 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

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

@rescript/belt

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 2423f75

@cristianoc
cristianoc force-pushed the codex/nary-dead-code branch from ddb086e to 69e3018 Compare August 20, 2026 07:49
@cristianoc
cristianoc force-pushed the codex/nary-dead-code branch 2 times, most recently from 7077ae8 to 2423f75 Compare August 20, 2026 09:16
- The Too_many_arguments error cannot be raised anymore: the expected
  type is committed to an arrow of the literal's shape before
  destructuring, so every legacy path now surfaces as a regular type
  clash or Uncurried_arity_mismatch (which is what the fixture credited
  to it in ERROR_VARIANTS.md was already producing). Remove the
  variant, its printer, and the ?in_function threading through
  type_expect/type_cases that existed only to decorate it.
- Remove the function$-vs-arrow unification bridge in ctype (nothing
  produces a function$ type expression anymore), the structural arity
  counter Ctype.arity (no callers), the parsetree arity probes
  get_uncurry_arity/get_curry_arity (is_arity_one reads the params list
  directly), and Ast_async's redundant newtype double-dig.
- Deduplicate the arrow-flattening step shared by the analysis
  extract_function_type helpers.
- Delete Ast_compatible outright. Every member was a thin veneer over
  an existing Ast_helper constructor (rec_type_str/rec_type_sig had
  byte-identical signatures to Str.type_/Sig.type_), hand-rolling the
  records the canonical constructors build; the OCaml-version
  compatibility it existed for is long gone, and its fun_ silently
  hard-coded arity 1. Call sites use Ast_helper directly, with two
  let-bound app1/app2 shorthands kept local to ast_derive_js_mapper.

Generated code is unchanged. The Pjs_fn_make no-op elision explored
alongside these cleanups is deliberately left out pending a dedicated
analysis of that primitive.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@cristianoc
cristianoc force-pushed the codex/nary-dead-code branch from 2423f75 to d1c949f Compare August 20, 2026 14:22
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