zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8c96d0dddddfb4cd597661ff47551fcaf67cbf39 (tree)
parent b6a5e52decf4494d9506caa929139b630ce08dea
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sat, 18 Feb 2023 11:44:38 -0700

update test-cases for new for loop syntax

Diffstat:
Mtest/cases/compile_errors/invalid_pointer_for_var_type.zig | 2+-
Mtest/cases/compile_errors/underscore_should_not_be_usable_inside_for.zig | 4++--
Mtest/cases/variable_shadowing.3.zig | 4++--
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/cases/compile_errors/invalid_pointer_for_var_type.zig b/test/cases/compile_errors/invalid_pointer_for_var_type.zig @@ -1,7 +1,7 @@ extern fn ext() usize; var bytes: [ext()]u8 = undefined; export fn f() void { - for (bytes) |*b, i| { + for (&bytes, 0..) |*b, i| { b.* = @as(u8, i); } } diff --git a/test/cases/compile_errors/underscore_should_not_be_usable_inside_for.zig b/test/cases/compile_errors/underscore_should_not_be_usable_inside_for.zig @@ -1,6 +1,6 @@ export fn returns() void { - for ([_]void{}) |_, i| { - for ([_]void{}) |_, j| { + for ([_]void{}, 0..) |_, i| { + for ([_]void{}, 0..) |_, j| { return _; } } diff --git a/test/cases/variable_shadowing.3.zig b/test/cases/variable_shadowing.3.zig @@ -1,10 +1,10 @@ pub fn main() void { var i = 0; - for ("n") |_, i| { + for ("n", 0..) |_, i| { } } // error // -// :3:19: error: loop index capture 'i' shadows local variable from outer scope +// :3:24: error: capture 'i' shadows local variable from outer scope // :2:9: note: previous declaration here