2023-02-18 19:26:22 +00:00
|
|
|
export fn a() void {
|
|
|
|
for (0..10, 10..21) |i, j| {
|
2023-06-15 08:14:16 +01:00
|
|
|
_ = i;
|
|
|
|
_ = j;
|
2023-02-18 19:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-18 20:22:29 +00:00
|
|
|
export fn b() void {
|
|
|
|
const s1 = "hello";
|
|
|
|
const s2 = true;
|
|
|
|
for (s1, s2) |i, j| {
|
2023-06-15 08:14:16 +01:00
|
|
|
_ = i;
|
|
|
|
_ = j;
|
2023-02-18 20:22:29 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-18 21:10:56 +00:00
|
|
|
export fn c() void {
|
|
|
|
var buf: [10]u8 = undefined;
|
|
|
|
for (buf) |*byte| {
|
|
|
|
_ = byte;
|
|
|
|
}
|
|
|
|
}
|
2023-02-18 22:58:27 +00:00
|
|
|
export fn d() void {
|
|
|
|
const x: [*]const u8 = "hello";
|
|
|
|
const y: [*]const u8 = "world";
|
|
|
|
for (x, 0.., y) |x1, x2, x3| {
|
2023-06-15 08:14:16 +01:00
|
|
|
_ = x1;
|
|
|
|
_ = x2;
|
|
|
|
_ = x3;
|
2023-02-18 22:58:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-18 19:26:22 +00:00
|
|
|
|
|
|
|
// error
|
|
|
|
// backend=stage2
|
|
|
|
// target=native
|
|
|
|
//
|
|
|
|
// :2:5: error: non-matching for loop lengths
|
|
|
|
// :2:11: note: length 10 here
|
|
|
|
// :2:19: note: length 11 here
|
2023-06-15 08:14:16 +01:00
|
|
|
// :10:14: error: type 'bool' is not indexable and not a range
|
|
|
|
// :10:14: note: for loop operand must be a range, array, slice, tuple, or vector
|
|
|
|
// :17:16: error: pointer capture of non pointer type '[10]u8'
|
|
|
|
// :17:10: note: consider using '&' here
|
|
|
|
// :24:5: error: unbounded for loop
|
|
|
|
// :24:10: note: type '[*]const u8' has no upper bound
|
|
|
|
// :24:18: note: type '[*]const u8' has no upper bound
|