| ... | @@ -1401,7 +1401,21 @@ test "continue in inline for inside a comptime switch" { | ... | @@ -1401,7 +1401,21 @@ test "continue in inline for inside a comptime switch" { |
| 1401 | try expect(count == 4); | 1401 | try expect(count == 4); |
| 1402 | } | 1402 | } |
| 1403 | | 1403 | |
| | 1404 | test "length of global array is determinable at comptime" { |
| | 1405 | const S = struct { |
| | 1406 | var bytes: [1024]u8 = undefined; |
| | 1407 | |
| | 1408 | fn foo() !void { |
| | 1409 | try std.testing.expect(bytes.len == 1024); |
| | 1410 | } |
| | 1411 | }; |
| | 1412 | comptime try S.foo(); |
| | 1413 | } |
| | 1414 | |
| 1404 | test "continue nested inline for loop" { | 1415 | test "continue nested inline for loop" { |
| | 1416 | // TODO: https://github.com/ziglang/zig/issues/13175 |
| | 1417 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| | 1418 | |
| 1405 | var a: u8 = 0; | 1419 | var a: u8 = 0; |
| 1406 | loop: inline for ([_]u8{ 1, 2 }) |x| { | 1420 | loop: inline for ([_]u8{ 1, 2 }) |x| { |
| 1407 | inline for ([_]u8{1}) |y| { | 1421 | inline for ([_]u8{1}) |y| { |
| ... | @@ -1415,13 +1429,21 @@ test "continue nested inline for loop" { | ... | @@ -1415,13 +1429,21 @@ test "continue nested inline for loop" { |
| 1415 | try expect(a == 2); | 1429 | try expect(a == 2); |
| 1416 | } | 1430 | } |
| 1417 | | 1431 | |
| 1418 | test "length of global array is determinable at comptime" { | 1432 | test "continue nested inline for loop in named block expr" { |
| 1419 | const S = struct { | 1433 | // TODO: https://github.com/ziglang/zig/issues/13175 |
| 1420 | var bytes: [1024]u8 = undefined; | 1434 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; |
| 1421 | | 1435 | |
| 1422 | fn foo() !void { | 1436 | var a: u8 = 0; |
| 1423 | try std.testing.expect(bytes.len == 1024); | 1437 | loop: inline for ([_]u8{ 1, 2 }) |x| { |
| 1424 | } | 1438 | a = b: { |
| 1425 | }; | 1439 | inline for ([_]u8{1}) |y| { |
| 1426 | comptime try S.foo(); | 1440 | if (x == y) { |
| | 1441 | continue :loop; |
| | 1442 | } |
| | 1443 | } |
| | 1444 | break :b x; |
| | 1445 | }; |
| | 1446 | try expect(x == 2); |
| | 1447 | } |
| | 1448 | try expect(a == 2); |
| 1427 | } | 1449 | } |