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:
1
tests/expected/192-pack-non-conform.exit
Normal file
1
tests/expected/192-pack-non-conform.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
5
tests/expected/192-pack-non-conform.txt
Normal file
5
tests/expected/192-pack-non-conform.txt
Normal 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
|
||||
| ^
|
||||
Reference in New Issue
Block a user