diff --git a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig index 8a2adb2f07..e63810c986 100644 --- a/test/cases/compile_errors/colliding_invalid_top_level_functions.zig +++ b/test/cases/compile_errors/colliding_invalid_top_level_functions.zig @@ -5,10 +5,9 @@ export fn entry() usize { } // error -// backend=stage2 -// target=native // -// :2:1: error: redeclaration of 'func' -// :1:1: note: other declaration here +// :1:4: error: duplicate struct member name 'func' +// :2:4: note: duplicate name here +// :1:1: note: struct declared here // :1:11: error: use of undeclared identifier 'bogus' // :2:11: error: use of undeclared identifier 'bogus' diff --git a/test/cases/compile_errors/decl_shadows_local.zig b/test/cases/compile_errors/decl_shadows_local.zig index 44066ab659..eeb69a4954 100644 --- a/test/cases/compile_errors/decl_shadows_local.zig +++ b/test/cases/compile_errors/decl_shadows_local.zig @@ -2,6 +2,7 @@ fn foo(a: usize) void { struct { const a = 1; }; + _ = a; } fn bar(a: usize) void { struct { @@ -18,5 +19,5 @@ fn bar(a: usize) void { // // :3:15: error: declaration 'a' shadows function parameter from outer scope // :1:8: note: previous declaration here -// :9:19: error: declaration 'a' shadows function parameter from outer scope -// :6:8: note: previous declaration here +// :10:19: error: declaration 'a' shadows function parameter from outer scope +// :7:8: note: previous declaration here diff --git a/test/cases/compile_errors/duplicate_enum_field.zig b/test/cases/compile_errors/duplicate_enum_field.zig index 02738f1b37..b3a4f4495b 100644 --- a/test/cases/compile_errors/duplicate_enum_field.zig +++ b/test/cases/compile_errors/duplicate_enum_field.zig @@ -12,6 +12,6 @@ export fn entry() void { // backend=stage2 // target=native // -// :2:5: error: duplicate enum field name -// :3:5: note: duplicate field here +// :2:5: error: duplicate enum member name 'Bar' +// :3:5: note: duplicate name here // :1:13: note: enum declared here diff --git a/test/cases/compile_errors/duplicate_struct_field.zig b/test/cases/compile_errors/duplicate_struct_field.zig index 954ed24e92..bb1ba26445 100644 --- a/test/cases/compile_errors/duplicate_struct_field.zig +++ b/test/cases/compile_errors/duplicate_struct_field.zig @@ -24,10 +24,10 @@ export fn b() void { // backend=stage2 // target=native // -// :2:5: error: duplicate struct field name -// :3:5: note: duplicate field here +// :2:5: error: duplicate struct member name 'Bar' +// :3:5: note: duplicate name here // :1:13: note: struct declared here -// :7:5: error: duplicate struct field name -// :9:5: note: duplicate field here -// :10:5: note: duplicate field here +// :7:5: error: duplicate struct member name 'a' +// :9:5: note: duplicate name here +// :10:5: note: duplicate name here // :6:11: note: struct declared here diff --git a/test/cases/compile_errors/duplicate_union_field.zig b/test/cases/compile_errors/duplicate_union_field.zig index b57842c1f7..912296ec2e 100644 --- a/test/cases/compile_errors/duplicate_union_field.zig +++ b/test/cases/compile_errors/duplicate_union_field.zig @@ -8,9 +8,7 @@ export fn entry() void { } // error -// backend=stage2 -// target=native // -// :2:5: error: duplicate union field name -// :3:5: note: duplicate field here +// :2:5: error: duplicate union member name 'Bar' +// :3:5: note: duplicate name here // :1:13: note: union declared here diff --git a/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig b/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig index ea799c561a..b880dd5992 100644 --- a/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig +++ b/test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig @@ -8,9 +8,7 @@ pub export fn entry() void { } // error -// backend=stage2 -// target=native // -// :3:9: error: duplicate struct field name -// :4:9: note: duplicate field here +// :3:9: error: duplicate struct member name 'e' +// :4:9: note: duplicate name here // :2:22: note: struct declared here diff --git a/test/cases/compile_errors/field_decl_name_conflict.zig b/test/cases/compile_errors/field_decl_name_conflict.zig new file mode 100644 index 0000000000..b71eb5b119 --- /dev/null +++ b/test/cases/compile_errors/field_decl_name_conflict.zig @@ -0,0 +1,18 @@ +foo: u32, +bar: u32, +qux: u32, + +const foo = 123; + +var bar: u8 = undefined; +fn bar() void {} + +// error +// +// :1:1: error: duplicate struct member name 'foo' +// :5:7: note: duplicate name here +// :1:1: note: struct declared here +// :2:1: error: duplicate struct member name 'bar' +// :7:5: note: duplicate name here +// :8:4: note: duplicate name here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/invalid_duplicate_test_decl_name.zig b/test/cases/compile_errors/invalid_duplicate_test_decl_name.zig index 2dd330912a..0e59795993 100644 --- a/test/cases/compile_errors/invalid_duplicate_test_decl_name.zig +++ b/test/cases/compile_errors/invalid_duplicate_test_decl_name.zig @@ -6,5 +6,6 @@ test "thingy" {} // target=native // is_test=true // -// :2:1: error: duplicate test name 'thingy' -// :1:1: note: other test here +// :1:6: error: duplicate test name 'thingy' +// :2:6: note: duplicate test here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/invalid_store_to_comptime_field.zig b/test/cases/compile_errors/invalid_store_to_comptime_field.zig index f3082b06a9..86ec05bf68 100644 --- a/test/cases/compile_errors/invalid_store_to_comptime_field.zig +++ b/test/cases/compile_errors/invalid_store_to_comptime_field.zig @@ -25,21 +25,21 @@ pub export fn entry3() void { const U = struct { comptime foo: u32 = 1, bar: u32, - fn foo(x: @This()) void { + fn qux(x: @This()) void { _ = x; } }; - _ = U.foo(U{ .foo = 2, .bar = 2 }); + _ = U.qux(U{ .foo = 2, .bar = 2 }); } pub export fn entry4() void { const U = struct { comptime foo: u32 = 1, bar: u32, - fn foo(x: @This()) void { + fn qux(x: @This()) void { _ = x; } }; - _ = U.foo(.{ .foo = 2, .bar = 2 }); + _ = U.qux(.{ .foo = 2, .bar = 2 }); } pub export fn entry5() void { comptime var y = .{ 1, 2 }; diff --git a/test/cases/compile_errors/multiple_function_definitions.zig b/test/cases/compile_errors/multiple_function_definitions.zig index 134daaeaa4..63522ca40d 100644 --- a/test/cases/compile_errors/multiple_function_definitions.zig +++ b/test/cases/compile_errors/multiple_function_definitions.zig @@ -5,8 +5,7 @@ export fn entry() void { } // error -// backend=stage2 -// target=native // -// :2:1: error: redeclaration of 'a' -// :1:1: note: other declaration here +// :1:4: error: duplicate struct member name 'a' +// :2:4: note: duplicate name here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/redefinition_of_enums.zig b/test/cases/compile_errors/redefinition_of_enums.zig index 34d5efe8df..0ccc7ec8dd 100644 --- a/test/cases/compile_errors/redefinition_of_enums.zig +++ b/test/cases/compile_errors/redefinition_of_enums.zig @@ -5,5 +5,6 @@ const A = enum { x }; // backend=stage2 // target=native // -// :2:1: error: redeclaration of 'A' -// :1:1: note: other declaration here +// :1:7: error: duplicate struct member name 'A' +// :2:7: note: duplicate name here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/redefinition_of_global_variables.zig b/test/cases/compile_errors/redefinition_of_global_variables.zig index 6f4ed225f7..9c224a30a9 100644 --- a/test/cases/compile_errors/redefinition_of_global_variables.zig +++ b/test/cases/compile_errors/redefinition_of_global_variables.zig @@ -5,5 +5,6 @@ var a: i32 = 2; // backend=stage2 // target=native // -// :2:1: error: redeclaration of 'a' -// :1:1: note: other declaration here +// :1:5: error: duplicate struct member name 'a' +// :2:5: note: duplicate name here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/redefinition_of_struct.zig b/test/cases/compile_errors/redefinition_of_struct.zig index 22852966db..da7b2fa4dd 100644 --- a/test/cases/compile_errors/redefinition_of_struct.zig +++ b/test/cases/compile_errors/redefinition_of_struct.zig @@ -5,5 +5,6 @@ const A = struct { y: i32 }; // backend=stage2 // target=native // -// :2:1: error: redeclaration of 'A' -// :1:1: note: other declaration here +// :1:7: error: duplicate struct member name 'A' +// :2:7: note: duplicate name here +// :1:1: note: struct declared here diff --git a/test/cases/compile_errors/struct_duplicate_field_name.zig b/test/cases/compile_errors/struct_duplicate_field_name.zig index 057083c3cb..207b40daf3 100644 --- a/test/cases/compile_errors/struct_duplicate_field_name.zig +++ b/test/cases/compile_errors/struct_duplicate_field_name.zig @@ -11,6 +11,6 @@ export fn entry() void { // error // target=native // -// :2:5: error: duplicate struct field name -// :3:5: note: duplicate field here +// :2:5: error: duplicate struct member name 'foo' +// :3:5: note: duplicate name here // :1:11: note: struct declared here diff --git a/test/cases/compile_errors/union_duplicate_enum_field.zig b/test/cases/compile_errors/union_duplicate_enum_field.zig index 21c307755b..3a350f923f 100644 --- a/test/cases/compile_errors/union_duplicate_enum_field.zig +++ b/test/cases/compile_errors/union_duplicate_enum_field.zig @@ -12,6 +12,6 @@ export fn foo() void { // error // target=native // -// :3:5: error: duplicate union field name -// :4:5: note: duplicate field here +// :3:5: error: duplicate union member name 'a' +// :4:5: note: duplicate name here // :2:11: note: union declared here diff --git a/test/cases/compile_errors/union_duplicate_field_definition.zig b/test/cases/compile_errors/union_duplicate_field_definition.zig index e0866964eb..4fca2a7b36 100644 --- a/test/cases/compile_errors/union_duplicate_field_definition.zig +++ b/test/cases/compile_errors/union_duplicate_field_definition.zig @@ -11,6 +11,6 @@ export fn entry() void { // error // target=native // -// :2:5: error: duplicate union field name -// :3:5: note: duplicate field here +// :2:5: error: duplicate union member name 'foo' +// :3:5: note: duplicate name here // :1:11: note: union declared here diff --git a/test/cases/function_redeclaration.zig b/test/cases/function_redeclaration.zig index b6cbf664a9..2b8dc4c15d 100644 --- a/test/cases/function_redeclaration.zig +++ b/test/cases/function_redeclaration.zig @@ -8,7 +8,8 @@ fn foo() void { // error // -// :3:1: error: redeclaration of 'entry' -// :2:1: note: other declaration here +// :2:4: error: duplicate struct member name 'entry' +// :3:4: note: duplicate name here +// :2:1: note: struct declared here // :6:9: error: local variable shadows declaration of 'foo' // :5:1: note: declared here diff --git a/test/cases/global_variable_redeclaration.zig b/test/cases/global_variable_redeclaration.zig index 9a0d5939fb..3970294b0d 100644 --- a/test/cases/global_variable_redeclaration.zig +++ b/test/cases/global_variable_redeclaration.zig @@ -4,5 +4,6 @@ var foo = true; // error // -// :3:1: error: redeclaration of 'foo' -// :2:1: note: other declaration here +// :2:5: error: duplicate struct member name 'foo' +// :3:5: note: duplicate name here +// :2:1: note: struct declared here diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 07ad178859..447984d277 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -92,7 +92,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void { \\const a = @import("a.zig"); \\ \\export fn entry() void { - \\ _ = a.S.foo(a.S{ .foo = 2, .bar = 2 }); + \\ _ = a.S.qux(a.S{ .foo = 2, .bar = 2 }); \\} , &[_][]const u8{ ":4:23: error: value stored in comptime field does not match the default value of the field", @@ -102,7 +102,7 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void { \\pub const S = struct { \\ comptime foo: u32 = 1, \\ bar: u32, - \\ pub fn foo(x: @This()) void { + \\ pub fn qux(x: @This()) void { \\ _ = x; \\ } \\};