aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJacob G-W <jacoblevgw@gmail.com>2021-07-14 18:03:15 -0400
committerJacob G-W <jacoblevgw@gmail.com>2021-07-14 18:03:15 -0400
commit759d1d9aeffbe1c5eaf7d5675b6d1c165757cdf1 (patch)
tree8e35f1531d3967705a23af6453929b75d9d34d95 /test
parent132b18e2b39feca3b90b1b13df2b4649b1661fd5 (diff)
downloadzig-759d1d9aeffbe1c5eaf7d5675b6d1c165757cdf1.tar.gz
zig-759d1d9aeffbe1c5eaf7d5675b6d1c165757cdf1.zip
astgen: errors for shadowing in loop captures
Diffstat (limited to 'test')
-rw-r--r--test/cases.zig43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/cases.zig b/test/cases.zig
index fe1579be44..f5eb566816 100644
--- a/test/cases.zig
+++ b/test/cases.zig
@@ -1065,6 +1065,49 @@ pub fn addCases(ctx: *TestContext) !void {
":5:19: error: redeclaration of local constant 'c'",
":4:19: note: previous declaration here",
});
+ case.addError(
+ \\pub fn main() void {
+ \\ var i = 0;
+ \\ for (n) |_, i| {
+ \\ }
+ \\}
+ , &[_][]const u8{
+ ":3:17: error: redeclaration of local variable 'i'",
+ ":2:9: note: previous declaration here",
+ });
+ case.addError(
+ \\pub fn main() void {
+ \\ var i = 0;
+ \\ for (n) |i| {
+ \\ }
+ \\}
+ , &[_][]const u8{
+ ":3:14: error: redeclaration of local variable 'i'",
+ ":2:9: note: previous declaration here",
+ });
+ case.addError(
+ \\pub fn main() void {
+ \\ var i = 0;
+ \\ while (n) |i| {
+ \\ }
+ \\}
+ , &[_][]const u8{
+ ":3:16: error: redeclaration of local variable 'i'",
+ ":2:9: note: previous declaration here",
+ });
+ case.addError(
+ \\pub fn main() void {
+ \\ var i = 0;
+ \\ while (n) |bruh| {
+ \\ _ = bruh;
+ \\ } else |i| {
+ \\
+ \\ }
+ \\}
+ , &[_][]const u8{
+ ":5:13: error: redeclaration of local variable 'i'",
+ ":2:9: note: previous declaration here",
+ });
}
{