aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors
diff options
context:
space:
mode:
authorJohn Schmidt <john.schmidt.h@gmail.com>2022-04-03 14:07:13 +0200
committerJohn Schmidt <john.schmidt.h@gmail.com>2022-04-03 14:30:32 +0200
commit6bbc2cd59af250ea164a4114e3d9fa15b27c2c8e (patch)
tree13714a34d95b4e216337b6496b08aff3ef93770c /test/compile_errors
parent174a889364d285e32534016f7425e8adaf9cab3c (diff)
downloadzig-6bbc2cd59af250ea164a4114e3d9fa15b27c2c8e.tar.gz
zig-6bbc2cd59af250ea164a4114e3d9fa15b27c2c8e.zip
sema: add compile error for duplicate struct field
Diffstat (limited to 'test/compile_errors')
-rw-r--r--test/compile_errors/stage2/struct_duplicate_field_name.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/compile_errors/stage2/struct_duplicate_field_name.zig b/test/compile_errors/stage2/struct_duplicate_field_name.zig
new file mode 100644
index 0000000000..274dce4e4a
--- /dev/null
+++ b/test/compile_errors/stage2/struct_duplicate_field_name.zig
@@ -0,0 +1,15 @@
+const S = struct {
+ foo: u32,
+ foo: u32,
+};
+
+export fn entry() void {
+ const s: S = .{ .foo = 100 };
+ _ = s;
+}
+
+// duplicate struct field name
+//
+// :3:5: error: duplicate struct field: 'foo'
+// :2:5: note: other field here
+// :1:11: note: struct declared here