From 00a47acb385d261eaa5590e368ce7532f2164ef1 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 14 Aug 2026 20:53:10 +0200 Subject: [PATCH] Remove dead code enabled by structural arity - 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 Signed-off-by: Cristiano Calcagno --- CHANGELOG.md | 2 + analysis/src/type_utils.ml | 23 ++-- compiler/frontend/ast_comb.ml | 9 -- compiler/frontend/ast_compatible.ml | 126 ------------------ compiler/frontend/ast_compatible.mli | 97 -------------- compiler/frontend/ast_core_type.ml | 8 +- compiler/frontend/ast_core_type.mli | 3 +- compiler/frontend/ast_core_type_class_type.ml | 14 +- compiler/frontend/ast_derive_abstract.ml | 4 +- compiler/frontend/ast_derive_js_mapper.ml | 32 ++--- compiler/frontend/ast_derive_projector.ml | 7 +- compiler/frontend/ast_exp_apply.ml | 8 +- compiler/frontend/ast_external_mk.ml | 9 +- compiler/frontend/ast_tdcls.ml | 7 +- compiler/ml/ast_async.ml | 11 +- compiler/ml/ctype.ml | 9 -- compiler/ml/ctype.mli | 1 - compiler/ml/typecore.ml | 61 +++------ compiler/ml/typecore.mli | 1 - compiler/syntax/src/res_core.ml | 4 +- tests/ERROR_VARIANTS.md | 6 +- 21 files changed, 87 insertions(+), 355 deletions(-) delete mode 100644 compiler/frontend/ast_compatible.ml delete mode 100644 compiler/frontend/ast_compatible.mli diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdb979a3ea..69409487802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ - Sync the platform npm package's compiler binaries (`packages/@rescript//bin`) via dune promotion on every `dune build`, instead of Makefile/CI copy steps that only ran when make did: a plain `dune build` can no longer leave `cli/*.js` and the test harnesses running a stale compiler. https://github.com/rescript-lang/rescript/pull/8560 - Remove unused compiler IR definitions, modules, helpers, error variants, and Typedtree fields. https://github.com/rescript-lang/rescript/pull/8551 https://github.com/rescript-lang/rescript/pull/8555 +- Cleanups enabled by structural arity: remove the unreachable `Too_many_arguments` error and the `?in_function` threading through the type checker that existed only to decorate it; remove the dead `function$`-vs-arrow unification bridge, `Ctype.arity`, and the unused parsetree arity helpers; deduplicate the analysis arrow-flattening helpers. https://github.com/rescript-lang/rescript/pull/8569 + - Make the typed layers n-ary as well: `Types.Tarrow` carries a parameter list, `Texp_function` carries typed parameters (label, ident, pattern, per-parameter exhaustiveness) and a body, and `Ttyp_arrow`/`Otyp_arrow` follow. The `arity` annotation and its `int option` phantom state are gone from the compiler entirely; `push_defaults` in translcore and the hand-rolled gather-until-arity walks in gentype, reanalyze, and the outcome printer are deleted. The cmi and cmt magic numbers are bumped (`Caml1999I023`/`Caml1999T023`). Generated JavaScript is byte-identical across the test suite (optional-parameter internals are named `*opt_