AstGen: add note pointing to tuple field

Closes #14188
This commit is contained in:
Veikka Tuominen 2023-01-10 15:07:48 +02:00
parent e2adf3b61a
commit 1658e4893d
2 changed files with 17 additions and 1 deletions

View File

@ -4487,9 +4487,24 @@ fn structDeclInner(
.container_field_align,
.container_field,
.@"comptime",
.test_decl,
=> continue,
else => {
return astgen.failNode(member_node, "tuple declarations cannot contain declarations", .{});
const tuple_member = for (container_decl.ast.members) |maybe_tuple| switch (node_tags[maybe_tuple]) {
.container_field_init,
.container_field_align,
.container_field,
=> break maybe_tuple,
else => {},
} else unreachable;
return astgen.failNodeNotes(
member_node,
"tuple declarations cannot contain declarations",
.{},
&[_]u32{
try astgen.errNoteNode(tuple_member, "tuple field here", .{}),
},
);
},
}
};

View File

@ -23,3 +23,4 @@ const T = struct {
// :5:5: error: union field missing name
// :8:5: error: tuple field has a name
// :15:5: error: tuple declarations cannot contain declarations
// :12:5: note: tuple field here