sema: add compile error for duplicate struct field

This commit is contained in:
John Schmidt
2022-04-03 14:07:13 +02:00
parent 174a889364
commit 6bbc2cd59a
2 changed files with 30 additions and 1 deletions

View File

@@ -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