From 8c96d0dddddfb4cd597661ff47551fcaf67cbf39 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Feb 2023 11:44:38 -0700 Subject: [PATCH] update test-cases for new for loop syntax --- test/cases/compile_errors/invalid_pointer_for_var_type.zig | 2 +- .../underscore_should_not_be_usable_inside_for.zig | 4 ++-- test/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 index ee193bab15..d94c7bd3b8 100644 --- 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 index 1fb79e11bd..b527d0d17e 100644 --- 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 index 1e22ccf123..3d899e72cc 100644 --- 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