aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-29 17:13:18 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-29 17:13:18 -0700
commit9e49a65e1bd474f0f678465fb4b965ddc5899226 (patch)
tree06a5c5982192f100dc6c0ecad8afba507e1ed579 /src/Sema.zig
parent55e86b724a2ce60b777bd94d1203f243435727b7 (diff)
downloadzig-9e49a65e1bd474f0f678465fb4b965ddc5899226.tar.gz
zig-9e49a65e1bd474f0f678465fb4b965ddc5899226.zip
AstGen: implement anytype struct fields
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig14
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);