| author | |
| committer | |
| log | 6cee98eb3074fcb99297f23f30e3a230a14e8db7 |
| tree | dba0265f7fe90862ac7c1dee3287eff5a69865c1 |
| parent | 4b7fa0fce90f05e13334bab5379d9e9ae8c5ae49 |
5 files changed, 17 insertions(+), 25 deletions(-)
src/AstGen.zig+7| ... | ... | @@ -4687,6 +4687,13 @@ fn structDeclInner( |
| 4687 | 4687 | const container_field = tree.fullContainerField(member_node) orelse continue; |
| 4688 | 4688 | if (container_field.ast.tuple_like) break true; |
| 4689 | 4689 | } else false; |
| 4690 | ||
| 4691 | if (is_tuple) switch (layout) { | |
| 4692 | .Auto => {}, | |
| 4693 | .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}), | |
| 4694 | .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}), | |
| 4695 | }; | |
| 4696 | ||
| 4690 | 4697 | if (is_tuple) for (container_decl.ast.members) |member_node| { |
| 4691 | 4698 | switch (node_tags[member_node]) { |
| 4692 | 4699 | .container_field_init, |
src/Sema.zig+6| ... | ... | @@ -20391,6 +20391,12 @@ fn reifyStruct( |
| 20391 | 20391 | const gpa = sema.gpa; |
| 20392 | 20392 | const ip = &mod.intern_pool; |
| 20393 | 20393 | |
| 20394 | if (is_tuple) switch (layout) { | |
| 20395 | .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}), | |
| 20396 | .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}), | |
| 20397 | .Auto => {}, | |
| 20398 | }; | |
| 20399 | ||
| 20394 | 20400 | // Because these three things each reference each other, `undefined` |
| 20395 | 20401 | // placeholders are used before being set after the struct type gains an |
| 20396 | 20402 | // InternPool index. |
src/codegen/llvm/Builder.zig+2-2| ... | ... | @@ -4164,8 +4164,8 @@ pub const WipFunction = struct { |
| 4164 | 4164 | @memcpy(extra.trail.nextMut(incoming_len, Block.Index, wip), blocks); |
| 4165 | 4165 | if (wip.builder.useLibLlvm()) { |
| 4166 | 4166 | const ExpectedContents = extern struct { |
| 4167 | [expected_incoming_len]*llvm.Value, | |
| 4168 | [expected_incoming_len]*llvm.BasicBlock, | |
| 4167 | values: [expected_incoming_len]*llvm.Value, | |
| 4168 | blocks: [expected_incoming_len]*llvm.BasicBlock, | |
| 4169 | 4169 | }; |
| 4170 | 4170 | var stack align(@alignOf(ExpectedContents)) = |
| 4171 | 4171 | std.heap.stackFallback(@sizeOf(ExpectedContents), wip.builder.gpa); |
test/behavior/tuple_declarations.zig-21| ... | ... | @@ -31,27 +31,6 @@ test "tuple declaration type info" { |
| 31 | 31 | try expect(!info.fields[1].is_comptime); |
| 32 | 32 | try expect(info.fields[1].alignment == @alignOf([]const u8)); |
| 33 | 33 | } |
| 34 | { | |
| 35 | const T = packed struct(u32) { u1, u30, u1 }; | |
| 36 | const info = @typeInfo(T).Struct; | |
| 37 | ||
| 38 | try expect(std.mem.endsWith(u8, @typeName(T), "test.tuple declaration type info.T")); | |
| 39 | ||
| 40 | try expect(info.layout == .Packed); | |
| 41 | try expect(info.backing_integer == u32); | |
| 42 | try expect(info.fields.len == 3); | |
| 43 | try expect(info.decls.len == 0); | |
| 44 | try expect(info.is_tuple); | |
| 45 | ||
| 46 | try expectEqualStrings(info.fields[0].name, "0"); | |
| 47 | try expect(info.fields[0].type == u1); | |
| 48 | ||
| 49 | try expectEqualStrings(info.fields[1].name, "1"); | |
| 50 | try expect(info.fields[1].type == u30); | |
| 51 | ||
| 52 | try expectEqualStrings(info.fields[2].name, "2"); | |
| 53 | try expect(info.fields[2].type == u1); | |
| 54 | } | |
| 55 | 34 | } |
| 56 | 35 | |
| 57 | 36 | test "Tuple declaration usage" { |
test/cases/compile_errors/reify_struct.zig+2-2| ... | ... | @@ -51,7 +51,7 @@ comptime { |
| 51 | 51 | .alignment = 4, |
| 52 | 52 | }}, |
| 53 | 53 | .decls = &.{}, |
| 54 | .is_tuple = true, | |
| 54 | .is_tuple = false, | |
| 55 | 55 | } }); |
| 56 | 56 | } |
| 57 | 57 | comptime { |
| ... | ... | @@ -65,7 +65,7 @@ comptime { |
| 65 | 65 | .alignment = 4, |
| 66 | 66 | }}, |
| 67 | 67 | .decls = &.{}, |
| 68 | .is_tuple = true, | |
| 68 | .is_tuple = false, | |
| 69 | 69 | } }); |
| 70 | 70 | } |
| 71 | 71 |