Skip to content

Commit 6a2cb96

Browse files
committed
AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes
Closes ziglang#8532
1 parent 683a119 commit 6a2cb96

14 files changed

+15
-15
lines changed

compile_errors/decl_shadows_local.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn bar(a: usize) void {
1616
// backend=stage2
1717
// target=native
1818
//
19-
// :3:15: error: redeclaration of function parameter 'a'
19+
// :3:15: error: declaration 'a' shadows function parameter from outer scope
2020
// :1:8: note: previous declaration here
21-
// :9:19: error: redeclaration of function parameter 'a'
21+
// :9:19: error: declaration 'a' shadows function parameter from outer scope
2222
// :6:8: note: previous declaration here

compile_errors/local_shadows_global_that_occurs_later.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ fn foo() void {}
88
// backend=stage2
99
// target=native
1010
//
11-
// :2:9: error: local shadows declaration of 'foo'
11+
// :2:9: error: local variable shadows declaration of 'foo'
1212
// :5:1: note: declared here

compile_errors/local_variable_redeclares_parameter.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export fn entry() void { f(1); }
77
// backend=stage2
88
// target=native
99
//
10-
// :2:11: error: redeclaration of function parameter 'a'
10+
// :2:11: error: local constant 'a' shadows function parameter from outer scope
1111
// :1:6: note: previous declaration here

compile_errors/local_variable_shadowing_global.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export fn entry() void {
1010
// backend=stage2
1111
// target=native
1212
//
13-
// :5:9: error: local shadows declaration of 'Bar'
13+
// :5:9: error: local variable shadows declaration of 'Bar'
1414
// :2:1: note: declared here

compile_errors/parameter_shadowing_global.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export fn entry() void {
88
// backend=stage2
99
// target=native
1010
//
11-
// :2:6: error: local shadows declaration of 'Foo'
11+
// :2:6: error: function parameter shadows declaration of 'Foo'
1212
// :1:1: note: declared here

function_redeclaration.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ fn foo() void {
1010
//
1111
// :3:1: error: redeclaration of 'entry'
1212
// :2:1: note: other declaration here
13-
// :6:9: error: local shadows declaration of 'foo'
13+
// :6:9: error: local variable shadows declaration of 'foo'
1414
// :5:1: note: declared here

variable_shadowing.1.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub fn main() void {
55

66
// error
77
//
8-
// :3:9: error: local shadows declaration of 'testing'
8+
// :3:9: error: local variable shadows declaration of 'testing'
99
// :1:1: note: declared here

variable_shadowing.3.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pub fn main() void {
66

77
// error
88
//
9-
// :3:19: error: redeclaration of local variable 'i'
9+
// :3:19: error: loop index capture 'i' shadows local variable from outer scope
1010
// :2:9: note: previous declaration here

variable_shadowing.4.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pub fn main() void {
66

77
// error
88
//
9-
// :3:16: error: redeclaration of local variable 'i'
9+
// :3:16: error: capture 'i' shadows local variable from outer scope
1010
// :2:9: note: previous declaration here

variable_shadowing.5.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ pub fn main() void {
66

77
// error
88
//
9-
// :3:18: error: redeclaration of local variable 'i'
9+
// :3:18: error: capture 'i' shadows local variable from outer scope
1010
// :2:9: note: previous declaration here

variable_shadowing.6.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ pub fn main() void {
99

1010
// error
1111
//
12-
// :5:13: error: redeclaration of local variable 'i'
12+
// :5:13: error: capture 'i' shadows local variable from outer scope
1313
// :2:9: note: previous declaration here

variable_shadowing.7.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub fn main() void {
55

66
// error
77
//
8-
// :3:16: error: redeclaration of local variable 'i'
8+
// :3:16: error: capture 'i' shadows local variable from outer scope
99
// :2:9: note: previous declaration here

variable_shadowing.8.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub fn main() void {
55

66
// error
77
//
8-
// :3:16: error: redeclaration of local variable 'i'
8+
// :3:16: error: capture 'i' shadows local variable from outer scope
99
// :2:9: note: previous declaration here

variable_shadowing.9.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub fn main() void {
55

66
// error
77
//
8-
// :3:28: error: redeclaration of local variable 'i'
8+
// :3:28: error: capture 'i' shadows local variable from outer scope
99
// :2:9: note: previous declaration here

0 commit comments

Comments
 (0)