ITADN

Consolidate the State/Exn handler naming machinery — remove the re-derivation generator behind the PR #1202 bug cluster

#1213Openaallan 创建于 24 天前
enhancementcodegen
A
aallancommented
## The finding PR #1202's four adversarial rounds handled roughly thirty distinct defects, and nearly all of them live in one place: the builtin State/Exn handler machinery at its intersection with type aliases and the checker/codegen naming boundary. Almost every bug had the same shape — **two sides re-derive the same fact independently and disagree**: - checker slot names vs codegen slot names (top-level opaque + arguments canonicalized vs fully opaque) - registration family names vs lowering family names - the bare, clause-inlined, and qualified dispatch paths for one `put` operation - the declared handler annotation vs the effect's cell type - monomorphization discovery vs the effect-op result-type mirror The corpus stayed green through every round (the 179 conformance programs and 42 examples never broke); the finds needed exotic spellings (`type Id<T> = T` applied twice, patternless `put()` clauses, alias-spelled clause patterns) and were overwhelmingly loud. The subsystem is not rotten — but the re-derivation seams are a bug *generator*, and point-fixes keep paying its tax. PR #1202's fixes already trended from patches to generator removals: one shared alias resolver (`vera/slots.py: resolve_alias_type_expr`) instead of ad-hoc walks, one shared equality (`vera.types.state_cell_decl_equal`) used by both the checker gate (E336) and the verifier's per-instantiation recheck (E533), the qualified `State.put`/`State.get` dispatchers delegating to the unqualified one so the spellings cannot drift by construction, and a differential-harness check-cleanliness assertion that kills fake-green fixtures as a class. This issue owns finishing the job. ## Member issues - #1208 — the global slot-naming seam (checker canonicalizes type-argument aliases on bind AND ref; codegen keeps both opaque outside handler clause scopes). **The big one**: the fix is a single naming module consumed by both checker and codegen, replacing `type_expr_slot_name`/`slot_ref_name`'s independent rendering. Touches every slot environment, wants its own PR and adversarial round. - #1211 — a bare op in a NESTED handler's clause body: checker targets the outer cell, codegen the inner. A **spec decision** (§7.5.2's lexical-scoping language suggests codegen's reading), then a one-sided alignment. - #1210 — the State/Exn registration scan never walks clause bodies, state-init expressions, or i32_pair cells (loud unknown-func/tag at module compile). - #1212 — Byte literals inside value-position joins lower at i64 into every i32 Byte boundary (shared with the `let` arm; one branch-descending lowering closes all #865 arms). - #1207 — monomorphization discovery vs `_effect_op_result_vera` clone naming desync (loud E602). - #1209 — whether `State<Alias>` of a composite names the SAME cell as `State<Composite>` (a design decision; scalar aliases already collapse per #1205). - Adjacent disclosure nuance: the call-argument narrowing arm records `guarded=True` for the `nat_to_int`/`nat_to_string` conversion builtins, whose argument site is #754's documented unguarded class. ## The plan (post-PR #1202, two-to-three PRs) 1. **The naming module** — one canonicalization API (opaque render, checker-canonical render, family resolution) with the alias tables threaded once, consumed by checker, codegen, and verifier. Closes #1208 and retires the whole mixed-spelling class; the scoped clause-body canonicalization from PR #1202 becomes a special case of the uniform rule and its seam note is deleted. 2. **The handler-semantics alignment** — the #1211 spec decision written into §7.5.2, the chosen side aligned, and #1210's registration walk extended to clause bodies/init exprs with a loud gate for i32_pair cells. 3. **(Smaller)** #1212's branch-descending Byte lowering; #1207's single-source clone naming; the #1209 decision. ## Keep the corner lit The adversarial probe programs from PR #1202's review rounds are the best handler test corpus this project has produced — the conformance suite demonstrably never covered alias × handler combinatorics. All 283 of them are captured in-repo at [`tests/probes/state_handlers/`](https://github.com/aallan/vera/tree/fix/779-985-fresh-scope-walkers/tests/probes/state_handlers) (landing with PR #1202; the README there states provenance and layout, and which probes deliberately fail as evidence of now-fixed or still-open defects). Promote the distinguishing ones into `tests/conformance/` (with manifest entries) as part of PR 1 so the corner stays covered permanently.
6 条评论