lang: inline for element form over packs — multi-iterable parity

This commit is contained in:
agra
2026-06-11 14:42:59 +03:00
parent 03dc10bba3
commit 40805e08ec
15 changed files with 277 additions and 40 deletions

View File

@@ -37,7 +37,7 @@ error: pack 'xs' has no runtime value — a pack is comptime-only and can't be u
17 | iter :: (..xs: Show) -> void { for xs (x) { _ = x; } } // D: runtime iterate
| ^^
help: to iterate at comptime use `inline for 0..xs.len (i)`; for a runtime loop declare it as `..xs: []P` (a protocol slice) instead of a pack
help: to iterate at comptime use `inline for xs (x)` (or `inline for 0..xs.len (i)` for the index); for a runtime loop declare it as `..xs: []P` (a protocol slice) instead of a pack
|
17 | iter :: (..xs: Show) -> void { for xs (x) { _ = x; } } // D: runtime iterate
| ^^

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,11 @@
bare: 7
bare: hi
0: 7
1: hi
r0: 1
r1: two
10 -> x
11 -> y
ran 3
val: IntBox{v: 42}
empty ok

View File

@@ -0,0 +1,23 @@
error: 'v' is not part of protocol 'Show' — a pack element exposes only the protocol's interface
--> examples/1164-diagnostics-inline-for-pack-rejections.sx:15:23
|
15 | print("{}\n", x.v);
| ^^^
error: a pack element cannot be captured by reference
--> examples/1164-diagnostics-inline-for-pack-rejections.sx:19:21
|
19 | inline for xs (*x) { }
| ^
error: inline for: pack 'xs' has 2 elements but the unroll is 5 iterations
--> examples/1164-diagnostics-inline-for-pack-rejections.sx:22:22
|
22 | inline for 0..5, xs (i, x) { }
| ^^
error: inline for: each iterable must be a comptime range or a pack — `inline for 0..N (i) { }` / `inline for xs (x) { }`
--> examples/1164-diagnostics-inline-for-pack-rejections.sx:30:16
|
30 | inline for arr (x) { }
| ^^^