Files
sx/examples/154-pack-type-rep.sx
agra bb6eca6b91 ffi M5.A.next.1c.A: pack type rep — lock in parser rejection
Next slice of the variadic heterogeneous type packs (`..$args`)
feature: type-system representation. Per the FFI cadence rule, this
commit locks in the parser-rejection behavior so the next commit's
type-rep extension surfaces as a behavior shift.

examples/154-pack-type-rep.sx uses `..$args` inside a `Closure(...)`
type expression — the pack-shape spelling used by impl headers like
`impl Into(Block) for Closure(..$args) -> $R`. Today's parser
recognizes `..$args` only at the parameter-list site (1b);
`parseTypeExpr`'s `Closure(...)` arm calls `parseTypeExpr` per
position and hits "expected type name" at the `..` token. Snapshot
captures the rejection at line 18, column 26.

Next commit (1c.B):
- Parser: `parseTypeExpr` Closure arm accepts `..$args` as the
  trailing pack marker. AST gets a `pack_name: ?[]const u8` (or
  equivalent) field on `ClosureTypeExpr`.
- types.zig: `FunctionInfo` / `ClosureInfo` gain `pack_start: ?u32`
  so the pack shape is distinct from any concrete arity in the
  type table. Hash/eql updated.
- type_bridge: `resolveClosureType` threads pack_start through.
- 154 flips green.

192/192 example tests + `zig build test` green.
2026-05-27 12:09:04 +03:00

24 lines
876 B
Plaintext

// Variadic heterogeneous type packs — `..$args` — type-system
// representation lock-in.
//
// Step 1c slice for the pack feature (see
// ~/.claude/plans/lets-see-options-for-merry-dijkstra.md). Exercises
// the parser's acceptance of `..$args` inside a `Closure(...)` type
// expression — the pack-shape spelling used by impl headers like
// `impl Into(Block) for Closure(..$args) -> $R`.
//
// Today's parser only accepts `..$args` in fn parameter lists (1b);
// the same syntax inside a `Closure(...)` type expression hits
// `expected type name` at the `..` token. This file pins that
// rejection. The next commit teaches `parseTypeExpr`'s `Closure(...)`
// arm + the type-table representation to carry the pack.
#import "modules/std.sx";
takes_cb :: (cb: Closure(..$args) -> $R) -> void { }
main :: () -> s32 {
print("pack type rep ok\n");
return 0;
}