From c7e997043f7509dce3ba99635775936fac250b9a Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 17 Jun 2026 07:45:08 +0300 Subject: [PATCH] docs(metatype): generic type-fn body locals done; only List growth remains --- current/CHECKPOINT-METATYPE.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/current/CHECKPOINT-METATYPE.md b/current/CHECKPOINT-METATYPE.md index 1d97c33f..32e22189 100644 --- a/current/CHECKPOINT-METATYPE.md +++ b/current/CHECKPOINT-METATYPE.md @@ -114,17 +114,15 @@ shifts every `.ir` snapshot. On-demand import keeps the prelude clean. ## Next step The reflect/construct triad is COMPLETE — `` `enum `` (`0619`), `` `struct `` (`0622`), `` `tuple `` (`0623`) all reflect AND construct + round-trip. Remaining -METATYPE work is the deferred enhancements (see below), all clean diagnostics -rather than crashes: +METATYPE work is ONE deferred enhancement, a clean diagnostic rather than a crash: - **Comptime `List` growth** — `List(EnumVariant).append` at comptime bails ("struct_get: base has no fields"); the allocator/List protocol path isn't fully - interp-evaluable. Probe `.sx-tmp/probe_makeenum.sx`. -- **Generic type-fn body locals** — a generic `($T) -> Type` comptime-evals only - its return EXPRESSION (`generic.zig:1760`); a local before the return is - unresolved. Workaround: non-generic builder (`examples/0620`). Probe - `.sx-tmp/probe_me5.sx`. -Neither blocks anything; the metatype surface (declare/define/type_info/field_type -+ make_enum) is feature-complete for the locked design. + interp-evaluable (heap alloc + protocol dispatch + List internals at comptime — + a deeper, multi-step interp effort). Probe `.sx-tmp/probe_makeenum.sx`. Doesn't + block anything: array-literal locals already work for building variant lists + (`examples/0620`/`0624`). +The metatype surface (declare/define/type_info/field_type + make_enum) is +feature-complete for the locked design; generic type-fn body locals now work too. - ~~**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 @@ -149,11 +147,10 @@ capabilities would let the variant list be built more freely; both error cleanly - **Comptime `List` growth.** Building variants via `List(EnumVariant).append` at comptime bails ("struct_get: base has no fields") — the allocator/List protocol path isn't fully interp-evaluable. Probe `.sx-tmp/probe_makeenum.sx`. -- **Generic type-fn body locals.** A *generic* `($T) -> Type` comptime-evals only - its return EXPRESSION (`generic.zig:1760`, `findReturnTypeExpr`), so a local - before the return is unresolved. Workaround: build the list inline in the return, - or use a non-generic `() -> Type` builder (whose whole body is evaluated — this - is what `examples/0620` uses). Probe `.sx-tmp/probe_me5.sx`. +- ~~Generic type-fn body locals~~ — DONE. A generic `($T) -> Type` now + comptime-evaluates its FULL body (prelude statements + return), so a local + before the return resolves. `createComptimeFunctionWithPrelude` + + `evalComptimeTypeBody`; no-prelude bodies stay on the old path. `examples/0624`. ## Known issues - issue 0140 — comptime type-construction bail panicked instead of diagnosing — @@ -167,6 +164,12 @@ capabilities would let the variant list be built more freely; both error cleanly `examples/1178` locks it). ## Log +- **Generic type-fn body locals.** A generic `($T) -> Type` comptime-evaluated + only its return EXPRESSION, so a local before the return was unresolved. Now a + body with a prelude (statements before the return) has its FULL body evaluated: + `createComptimeFunctionWithPrelude` lowers the pre-return statements into the + comptime function's scope, then the return expr. No-prelude bodies (RecvResult + etc.) stay on the old path → zero regression. `examples/0624`. Suite green (685). - **Tuple widening done — reflect/construct triad complete.** `TypeInfo` gained `` `tuple(TupleInfo) `` (positional `[]Type`); `reflectTypeInfo` reflects a `.tuple` (bare type_tags, tag 2), `defineType` dispatches tag 2 → `defineTuple`