lang 2.4: enforce protocol-pack conformance per position

Each argument bound to a `..xs: P` pack must conform to P — previously the
constraint was decorative (any type was accepted). `lowerPackFnCall` now
captures the pack param's constraint protocol and checks each pack arg via a
new `packArgConformsTo`, which accepts: a plain-protocol impl
(`protocol_thunk_map`), any parameterised impl `P(<args>) for T` (scan of
`param_impl_map` for a `P\x00…\x00mangle(T)` key — the per-element type-args
are inferred from the impl, not written out), or an arg already erased to P's
own protocol struct. Non-conformers get a per-position error pointing at the
argument. Only enforced for a known protocol constraint.

Regression: examples/192-pack-non-conform.sx (a struct lacking `impl Show` in a
`..xs: Show` pack → diagnostic, exit 1).
This commit is contained in:
agra
2026-05-29 18:01:48 +03:00
parent 934585ac74
commit fc4d239fdd
4 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,5 @@
error: pack argument of type 'Naked' does not conform to protocol 'Show'
--> /Users/agra/projects/sx/examples/192-pack-non-conform.sx:22:30
|
22 | print("{}\n", howmany(a, n)); // `n` does not conform to Show
| ^