ffi M5.A.next.2b.fu34.B: pack-mono materialises []Any slice for bare args

Fixes follow-ups #3 (bare `args` reference) and #4
(`args[<runtime_int>]`) from step 2b. The pack-mono now
materialises an `[]Any` slice value for the pack name at body
entry: each pack-param slot is loaded, boxed via `boxAny`, and
stored into a stack [N x Any] array; the slice {data_ptr, len}
binds to the pack name in scope.

Plumbing in src/ir/lower.zig:

- `materialisePackSlice(scope, pack_name, slot_refs, arg_types)`
  — new helper that emits the array alloca + box+store loop +
  slice alloca + bind. Empty-pack case (N == 0) emits {null, 0}
  directly.
- `monomorphizePackFn` captures the pack-param slot Refs as
  they bind, then calls `materialisePackSlice` after binding so
  the slice load can pull each param value.

After: `args` (bare) resolves as `[]Any` and forwards to
slice-typed helpers; `args[<runtime_int>]` lowers through the
standard slice-indexing path, element type `Any`. Per-position
type info is lost via Any boxing — that is the inherent cost
of treating a heterogeneous pack as a uniform value. Literal-
indexed access still routes through `packArgNodeAt` and keeps
the concrete per-position types.

`examples/162-pack-bare-args.sx` flips from "unresolved 'args'"
to `3` (forwarded to `log_count(items: []Any)` which returns
`items.len`).

`examples/163-pack-runtime-index.sx` flips from the LLVM
verifier crash to `4` (while-loop over `args.len`, indexing
each `args[i]` runtime).

202/202 example tests + `zig build test` green.
This commit is contained in:
agra
2026-05-27 16:41:28 +03:00
parent dadf80b3f1
commit d30d566397
5 changed files with 68 additions and 8 deletions

View File

@@ -1 +1 @@
1
0

View File

@@ -1 +1 @@
/Users/agra/projects/sx/examples/162-pack-bare-args.sx:23:22: error: unresolved 'args' (in /Users/agra/projects/sx/examples/162-pack-bare-args.sx fn forward__pack_s64_string_f64)
3

View File

@@ -1 +1 @@
1
0

View File

@@ -1,5 +1 @@
LLVM verification failed: GEP base pointer is not a vector or a vector of pointers
%ig.ptr = getelementptr i64, i64 %ig.data, %load7
Load operand must be a pointer.
%ig.val = load i64, i64 %ig.ptr, align 8
4