diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-04-29 17:13:18 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-04-29 17:13:18 -0700 |
| commit | 9e49a65e1bd474f0f678465fb4b965ddc5899226 (patch) | |
| tree | 06a5c5982192f100dc6c0ecad8afba507e1ed579 /src/Sema.zig | |
| parent | 55e86b724a2ce60b777bd94d1203f243435727b7 (diff) | |
| download | zig-9e49a65e1bd474f0f678465fb4b965ddc5899226.tar.gz zig-9e49a65e1bd474f0f678465fb4b965ddc5899226.zip | |
AstGen: implement anytype struct fields
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index b99c31debb..224d61ca24 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -750,10 +750,16 @@ pub fn zirStructDecl( // This string needs to outlive the ZIR code. const field_name = try new_decl_arena.allocator.dupe(u8, field_name_zir); - // TODO: if we need to report an error here, use a source location - // that points to this type expression rather than the struct. - // But only resolve the source location if we need to emit a compile error. - const field_ty = try sema.resolveType(block, src, field_type_ref); + if (field_type_ref == .none) { + return sema.mod.fail(&block.base, src, "TODO: implement anytype struct field", .{}); + } + const field_ty: Type = if (field_type_ref == .none) + Type.initTag(.noreturn) + else + // TODO: if we need to report an error here, use a source location + // that points to this type expression rather than the struct. + // But only resolve the source location if we need to emit a compile error. + try sema.resolveType(block, src, field_type_ref); const gop = struct_obj.fields.getOrPutAssumeCapacity(field_name); assert(!gop.found_existing); |
