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:
@@ -688,6 +688,12 @@ pub const Parser = struct {
|
||||
};
|
||||
self.advance();
|
||||
try args.append(self.allocator, try self.createNode(arg_start, .{ .int_literal = .{ .value = value } }));
|
||||
} else if (self.current.tag == .dot_dot) {
|
||||
// Pack-spread type arg: `Combined($R, ..sources.T)`.
|
||||
const sp_start = self.current.loc.start;
|
||||
self.advance(); // skip '..'
|
||||
const operand = try self.parseTypeExpr();
|
||||
try args.append(self.allocator, try self.createNode(sp_start, .{ .spread_expr = .{ .operand = operand } }));
|
||||
} else {
|
||||
try args.append(self.allocator, try self.parseTypeExpr());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user