lang: inline for element form over packs — multi-iterable parity
This commit is contained in:
@@ -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
|
||||
| ^^
|
||||
|
||||
1
examples/expected/0545-packs-inline-for-element.exit
Normal file
1
examples/expected/0545-packs-inline-for-element.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/expected/0545-packs-inline-for-element.stderr
Normal file
1
examples/expected/0545-packs-inline-for-element.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
11
examples/expected/0545-packs-inline-for-element.stdout
Normal file
11
examples/expected/0545-packs-inline-for-element.stdout
Normal 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
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -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) { }
|
||||
| ^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user