lang 2.4: bind protocol-constrained packs (per-shape mono, concrete elements)
`..xs: Protocol` now binds like the comptime `..$args` pack instead of falling through to a runtime `[]Protocol` slice: each call site monomorphizes with the concrete per-position arg types, and `xs[i]` is the concrete element via AST substitution (Decision 1 — a pack is a comptime mechanism, no runtime pack value). So `xs[i]`'s own fields/methods dispatch statically and elements may be heterogeneous, while `xs.len` is a comptime constant. Mechanism: one `isPackParam(p) = is_variadic and (is_comptime or is_pack)` predicate replaces the four `is_variadic and is_comptime` pack-detection sites (call-arg split, mangle, arg lowering, monomorphizePackFn), and the early call dispatch routes any `isPackFn` call to `lowerPackFnCall` before the `hasComptimeParams` gate (which is false for a protocol pack). examples/191-protocol-pack.sx exercises N=0, N=2, concrete field access, and a heterogeneous IntBox+StrBox pack. Conformance checking and projection (`xs.T` / `xs.value`) are the remaining 2.4 work.
This commit is contained in:
1
tests/expected/191-protocol-pack.exit
Normal file
1
tests/expected/191-protocol-pack.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
4
tests/expected/191-protocol-pack.txt
Normal file
4
tests/expected/191-protocol-pack.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
count0=0
|
||||
count2=2
|
||||
sum=49
|
||||
describe len=2 first=42 second=cool
|
||||
Reference in New Issue
Block a user