From bb6eca6b918e24343c2e094ab7a402b2bd63c692 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 27 May 2026 12:09:04 +0300 Subject: [PATCH] =?UTF-8?q?ffi=20M5.A.next.1c.A:=20pack=20type=20rep=20?= =?UTF-8?q?=E2=80=94=20lock=20in=20parser=20rejection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- examples/154-pack-type-rep.sx | 23 +++++++++++++++++++++++ tests/expected/154-pack-type-rep.exit | 1 + tests/expected/154-pack-type-rep.txt | 1 + 3 files changed, 25 insertions(+) create mode 100644 examples/154-pack-type-rep.sx create mode 100644 tests/expected/154-pack-type-rep.exit create mode 100644 tests/expected/154-pack-type-rep.txt diff --git a/examples/154-pack-type-rep.sx b/examples/154-pack-type-rep.sx new file mode 100644 index 0000000..582d84e --- /dev/null +++ b/examples/154-pack-type-rep.sx @@ -0,0 +1,23 @@ +// 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; +} diff --git a/tests/expected/154-pack-type-rep.exit b/tests/expected/154-pack-type-rep.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/154-pack-type-rep.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/154-pack-type-rep.txt b/tests/expected/154-pack-type-rep.txt new file mode 100644 index 0000000..a324bd9 --- /dev/null +++ b/tests/expected/154-pack-type-rep.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/154-pack-type-rep.sx:18:26: error: expected type name