You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Switch defensive raise sites to assert false; revert typemod/Misplaced_label_syntax
PR-review feedback: replacing dead raise sites with Location.raise_errorf
moves code rather than removing it, and introduces a pattern that doesn't
exist anywhere else in the typer modules (which use raise (Error ...) for
real errors and assert false for unreachable defensive code; zero inline
Location.raise_errorf calls in master).
This commit aligns the cleanup with the existing convention:
1. Variants whose raise sites are confirmed unreachable from the ReScript
parser have those sites rewritten to `assert false (* reason *)` with
a comment citing the parser block or sibling check. The named variant
(decl + reporter) stays removed.
- typecore.Invalid_interval, Invalid_for_of_pattern (parser blocks /
normalizes the AST)
- typetexp.Unbound_type_constructor_2, Ill_typed_functor_application,
Apply_structure_as_functor (parser doesn't construct Lapply or
bare-Tvar Tconstr body)
- typedecl.Type_clash, Parameters_differ (Cycle_in_def fires first),
Null_arity_external (Primitive.parse_declaration sets prim_native_name
always), Bad_fixed_type (is_fixed_type and expand_head agree),
Varying_anonymous (parser rejects `_` type params), Val_in_structure
(parser rejects val outside .resi)
- bs_syntaxerr.Unhandled_poly_type (parser misreads inline 'a. as
deprecated uncurried syntax)
- env.Illegal_value_name (parser doesn't emit '->' or # identifiers)
- typecore.Incoherent_label_order: collapsed into Apply_wrong_label
with a comment explaining why the original second arm was
unreachable
2. Variants where reproduction confirmed they ARE reachable, or where I
couldn't prove unreachability, are restored to named-variant form:
- typemod.Cannot_eliminate_dependency (couldn't reproduce, but
reachable from non-generative functor application paths in
principle - retained conservatively)
- typemod.With_makes_applicative_functor_ill_typed (couldn't reproduce
- retained conservatively)
- typemod.With_cannot_remove_constrained_type (REACHABLE via
destructive substitution on a constrained type, fixture
with_cannot_remove_constrained_type.res)
- typemod.Scoping_pack (couldn't reproduce - retained conservatively)
- bs_syntaxerr.Misplaced_label_syntax (REACHABLE via operator-as-
identifier syntax with labelled arg, fixture
misplaced_label_syntax.res)
3. tests/ERROR_VARIANTS.md updated to (a) split the Removed section into
"Truly dead" and "Defensive unreachable" categories, (b) note the
restored typemod variants with `?` status, (c) add covered rows for
the two new fixtures.
Truly-dead removals (no raise site, transitively dead, or always-false
guard) are unchanged: 3 Ctype exceptions, 2 relay variants
(typecore.Recursive_local_constraint, typetexp.Variant_tags),
bs_syntaxerr.Conflict_bs_bs_this_bs_meth, 14 warning constructors.
Validation: rg confirmed no remaining references to the removed
variants. make compiler, super_errors (745 fixtures), super_errors_multi
(54 fixtures) all pass. make checkformat clean.
0 commit comments