astgen: errors for shadowing in if captures

This commit is contained in:
Jacob G-W
2021-07-14 18:17:55 -04:00
parent 759d1d9aef
commit 1799455e05
2 changed files with 30 additions and 0 deletions
+27
View File
@@ -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",
});
}
{