docs(metatype): validation story complete (use-before-define subsumed)

This commit is contained in:
agra
2026-06-17 06:42:27 +03:00
parent dcdf1dd318
commit afb1fee252

View File

@@ -93,12 +93,16 @@ Pick any (independent):
add `` .`struct ``/`` .`tuple `` to the `TypeInfo` enum in `meta.sx`, teach
`reflectTypeInfo` to build them, and teach `defineEnum` (→ a `defineType`) to
decode them. Round-trips a struct through `define` once it lands.
- **Validation + loud diagnostics** (remaining) — ~~duplicate variant names~~ DONE
(`define` bails naming the dup; `examples/1180`); ~~`declare()` never
`define()`d~~ DONE (`evalComptimeType` rejects a zero-variant result; was a
`verifySizes` panic; `examples/1181`). Still pending: use-before-define (using a
declared-but-not-yet-defined slot's LAYOUT mid-construction; `*Name` pointer use
is fine and by-VALUE self-ref is already caught by `checkInfiniteSize`/issue 0139).
- ~~**Validation + loud diagnostics**~~ — COMPLETE. duplicate variant names
(`examples/1180`); `declare()` never `define()`d (`examples/1181`, was a
`verifySizes` panic); by-value self-reference for both source (`1178`) and
CONSTRUCTED (`1182`) types via `checkInfiniteSize`. **use-before-define needs no
new check** — it's subsumed by the existing guards: a by-value cycle →
`checkInfiniteSize` ("infinitely sized"); an unfinished slot → declare-never-
defined; a bad/non-Type payload → a 0140 clean bail; a forward reference resolves
correctly via in-place slot mutation (`updatePreservingKey`); a `*Name` pointer
needs no layout. Probes `.sx-tmp/probe_ubd{1..4}.sx` confirmed: no remaining
crash or silent-corruption, only clean diagnostics / correct results.
### make_enum follow-ups (deferred capability gaps — NOT crashes; clean diagnostics)
`make_enum` itself is DONE (see Last completed step). Remaining adjacent
@@ -131,6 +135,12 @@ capabilities would let the variant list be built more freely; both error cleanly
`examples/1178` locks it).
## Log
- **Validation story COMPLETE.** use-before-define needs no new check — subsumed
by `checkInfiniteSize` (by-value cycles), declare-never-defined (unfinished
slots), 0140 bails (bad payloads), and in-place slot mutation (forward refs);
`*Name` pointer use needs no layout. Probed `.sx-tmp/probe_ubd{1..4}.sx`: all
clean diagnostics / correct results, no crash. `examples/1182` locks the
by-value self-ref rejection for CONSTRUCTED enums (companion to source `1178`).
- **declare()-never-defined validation.** A bare `declare("X")` with no `define`
left a zero-field nominal slot that panicked at codegen (`verifySizes`).
`evalComptimeType` now detects a zero-variant `tagged_union` result and emits a