mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
astgen: errors for shadowing in if captures
This commit is contained in:
@@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user