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:
26
examples/0525-packs-pack-as-type-slice-arg.sx
Normal file
26
examples/0525-packs-pack-as-type-slice-arg.sx
Normal file
@@ -0,0 +1,26 @@
|
||||
// Regression (issue 0143): a variadic `..$args` pack forwarded as a `[]Type`
|
||||
// ARGUMENT across a call must read the right element types. The pack-slice
|
||||
// materialization (`buildPackSliceValue`) built a `[]Any` (16-byte) array while
|
||||
// `Type` is now `.type_value` (8 bytes) — 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.
|
||||
#import "modules/std.sx";
|
||||
|
||||
inner :: (args: []Type) -> string {
|
||||
s := "";
|
||||
i : i64 = 0;
|
||||
while i < args.len {
|
||||
s = concat(s, type_name(args[i]));
|
||||
s = concat(s, " ");
|
||||
i = i + 1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
outer :: (..$args) -> string { return inner($args); }
|
||||
|
||||
R :: #run outer(42, "hi", true);
|
||||
|
||||
main :: () {
|
||||
print("[{}]\n", R);
|
||||
}
|
||||
1
examples/expected/0525-packs-pack-as-type-slice-arg.exit
Normal file
1
examples/expected/0525-packs-pack-as-type-slice-arg.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
[i64 string bool ]
|
||||
Reference in New Issue
Block a user