lang F1 6: pack-spread in parameterized-type args (Combined($R, ..sources.T))
Parser now accepts a `..` spread in a parameterized-type arg list; in instantiateGenericStruct a spread arg bound to the variadic type-param expands via packTypeElems (so `..sources.T` projects each source pack element protocol type-arg into ..$Ts). `Combined(s64, ..sources.T)` for a VL(s64) source instantiates Combined(s64, s64). examples/209 (with explicit per-element xx erase). 244 examples + unit green. Next: (..sources) whole-pack materialization with per-element erasure into the protocol-typed field (c.sources = (..sources) currently segfaults).
This commit is contained in:
@@ -11495,6 +11495,19 @@ pub const Lowering = struct {
|
||||
if (tp.is_variadic) {
|
||||
var pack_tys = std.ArrayList(TypeId).empty;
|
||||
for (args[i..]) |a| {
|
||||
// A spread arg `..sources.T` expands to the source pack's
|
||||
// per-element (projected) types; a plain arg is one type.
|
||||
if (a.data == .spread_expr) {
|
||||
if (self.packTypeElems(a.data.spread_expr.operand)) |elems| {
|
||||
defer self.alloc.free(elems);
|
||||
for (elems) |ty| {
|
||||
pack_tys.append(self.alloc, ty) catch {};
|
||||
name_parts.appendSlice(self.alloc, "__") catch {};
|
||||
name_parts.appendSlice(self.alloc, self.formatTypeName(ty)) catch {};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const ty = self.resolveTypeWithBindings(a);
|
||||
pack_tys.append(self.alloc, ty) catch {};
|
||||
name_parts.appendSlice(self.alloc, "__") catch {};
|
||||
|
||||
Reference in New Issue
Block a user