diff options
| author | Jacob G-W <jacoblevgw@gmail.com> | 2021-07-14 18:17:55 -0400 |
|---|---|---|
| committer | Jacob G-W <jacoblevgw@gmail.com> | 2021-07-14 18:17:55 -0400 |
| commit | 1799455e0587644c98cdba67bd10a59a2d45b116 (patch) | |
| tree | 6539087c26b1984a0fc3ed391efdb1955d79bf01 /test/cases.zig | |
| parent | 759d1d9aeffbe1c5eaf7d5675b6d1c165757cdf1 (diff) | |
| download | zig-1799455e0587644c98cdba67bd10a59a2d45b116.tar.gz zig-1799455e0587644c98cdba67bd10a59a2d45b116.zip | |
astgen: errors for shadowing in if captures
Diffstat (limited to 'test/cases.zig')
| -rw-r--r-- | test/cases.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/cases.zig b/test/cases.zig index f5eb566816..f235992f71 100644 --- a/test/cases.zig +++ b/test/cases.zig @@ -1108,6 +1108,33 @@ pub fn addCases(ctx: *TestContext) !void { ":5:13: error: redeclaration of local variable 'i'", ":2:9: note: previous declaration here", }); + case.addError( + \\pub fn main() void { + \\ var i = 0; + \\ if (true) |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; + \\ if (true) |i| {} else |e| {} + \\} + , &[_][]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; + \\ if (true) |_| {} else |i| {} + \\} + , &[_][]const u8{ + ":3:28: error: redeclaration of local variable 'i'", + ":2:9: note: previous declaration here", + }); } { |
