authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-10 15:07:48+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-11 21:11:21+02:00
log1658e4893d749c7d1ed378cd34b6cbe1a132c0e9
tree96afbdec91289ba12f4e8f2070028fcad2233f44
parente2adf3b61a32eae2182bcb94981a0b3706040f9a

AstGen: add note pointing to tuple field

Closes #14188

2 files changed, 17 insertions(+), 1 deletions(-)

src/AstGen.zig+16-1
...@@ -4487,9 +4487,24 @@ fn structDeclInner(...@@ -4487,9 +4487,24 @@ fn structDeclInner(
4487 .container_field_align,4487 .container_field_align,
4488 .container_field,4488 .container_field,
4489 .@"comptime",4489 .@"comptime",
4490 .test_decl,
4490 => continue,4491 => continue,
4491 else => {4492 else => {
4492 return astgen.failNode(member_node, "tuple declarations cannot contain declarations", .{});4493 const tuple_member = for (container_decl.ast.members) |maybe_tuple| switch (node_tags[maybe_tuple]) {
4494 .container_field_init,
4495 .container_field_align,
4496 .container_field,
4497 => break maybe_tuple,
4498 else => {},
4499 } else unreachable;
4500 return astgen.failNodeNotes(
4501 member_node,
4502 "tuple declarations cannot contain declarations",
4503 .{},
4504 &[_]u32{
4505 try astgen.errNoteNode(tuple_member, "tuple field here", .{}),
4506 },
4507 );
4493 },4508 },
4494 }4509 }
4495 };4510 };
test/cases/compile_errors/tuple_declarations.zig+1
...@@ -23,3 +23,4 @@ const T = struct {...@@ -23,3 +23,4 @@ const T = struct {
23// :5:5: error: union field missing name23// :5:5: error: union field missing name
24// :8:5: error: tuple field has a name24// :8:5: error: tuple field has a name
25// :15:5: error: tuple declarations cannot contain declarations25// :15:5: error: tuple declarations cannot contain declarations
26// :12:5: note: tuple field here