fix issue 0143: pack-as-[]Type built as []Any — build it as []type_value

buildPackSliceValue (lower/pack.zig) materialized a bare `$<pack>` []Type slice
as []Any (16-byte elements) — a stale mapping from before the dedicated Type
builtin (.type_value, 8 bytes) replaced Type -> .any. It stored 8-byte const_type
words into 16-byte slots, so a []Type reader (8-byte stride) read [t0, pad, t1, ...]
instead of [t0, t1, ...]. The legacy interp's tagged-Value model hid it; the
byte-accurate comptime VM exposed it (a `..$args` pack forwarded as a []Type
argument across a call read its elements shifted/garbled).

Fix: build the pack-slice array + slice as .type_value (8 bytes). Removed the
stopgap type_name .unresolved guard (379ed05) now that the root cause is fixed.

Regression test examples/0525-packs-pack-as-type-slice-arg.sx (outer(42,"hi",true)
-> inner($args: []Type) -> "i64 string bool"). 700/0 both gates; issue 0143 RESOLVED.
This commit is contained in:
agra
2026-06-18 19:42:42 +03:00
parent a446550013
commit f807436f04
7 changed files with 58 additions and 24 deletions

View File

@@ -1,3 +1,12 @@
> **RESOLVED (2026-06-18).** Root cause: `buildPackSliceValue` (`src/ir/lower/pack.zig`)
> built the `$<pack>` `[]Type` slice as `[]Any` (16-byte elements) — a stale mapping
> from before the dedicated `Type` builtin (`.type_value`, 8 bytes) replaced `Type → .any`.
> It stored 8-byte `const_type` words into 16-byte slots, so a `[]Type` reader (8-byte
> stride) read `[t0, pad, t1, …]`. Fix: build the slice/array as `.type_value` (8 bytes).
> Regression test: `examples/0525-packs-pack-as-type-slice-arg.sx`. The stopgap
> `type_name` `.unresolved` guard added in 379ed05 was removed (root cause fixed).
> 700/0 both gates.
# 0143 — A variadic pack passed as `[]Type` across a call is mis-strided (Any-sized backing, Type-sized view)
**Symptom** — When a variadic `..$args` pack is forwarded as a `[]Type` *argument*