lang 1.2: parse pack-expansion forms in all four positions

Pack/tuple spread now parses in tuple-value `(..xs)` / `(..xs.field)`,
tuple-type `(..F(Ts))` / `(..F(Ts.Arg))`, call-arg `f(..xs)` (already),
and closure-sig `Closure(..Ts)` / `Closure(..sources.T)` positions.

Design: the uniform spread node is the existing `spread_expr` (its
operand sub-expression carries the projection `xs.field` and
type-application `F(Ts)` shapes) rather than a new PackExpansion node —
call-arg slice-spread (`..arr`) and pack-spread (`..pack`) are
syntactically identical, so they must share one node, and spread_expr
already serves it with working slice lowering. Closure-sig packs gain
`ClosureTypeExpr.pack_projection` alongside the existing `pack_name`.

Parser-only; sema/lowering land in Phase 2. 6 new parser unit tests +
examples/probes/pack-expansion-parses.sx. Build + 225-suite green.
This commit is contained in:
agra
2026-05-29 12:33:27 +03:00
parent 87f739cef2
commit 98526ab9b4
3 changed files with 161 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
// Feature 1 / Step 1.2 — pack-expansion forms PARSE in all four positions.
//
// Parse-only probe. Spread reuses the existing `spread_expr` node (its operand
// carries projection `xs.field` / type-application `F(Ts)`); closure-sig packs
// use `ClosureTypeExpr.pack_name` + the new `pack_projection`. Sema/lowering
// arrive in Phase 2 — do NOT expect this to compile/run yet. The authoritative
// checks are the parser unit tests in src/parser.zig ("parse pack expansion: …").
// 1. Tuple value position — `(..pack)` / `(..pack.field)`:
tv1 :: () => (..xs);
tv2 :: () => (..xs.value);
tv3 :: () => (a, ..xs, b); // mixed positional + spread
// 2. Tuple type position — `(..F(Ts))` / `(..F(Ts.Arg))`:
tt1 :: (x: (..ValueListenable(Ts))) => x;
tt2 :: (x: (..ValueListenable(Ts.Arg))) => x;
// 3. Call-arg position — `..pack` / `..pack.field` (reuses spread_expr):
ca1 :: () => f(..xs);
ca2 :: () => f(..xs.value);
// 4. Closure-sig position — `Closure(..Ts)` / `Closure(..Ts.Arg)`:
cs1 :: (cb: Closure(..Ts) -> s32) => cb;
cs2 :: (cb: Closure(..sources.T) -> s32) => cb;