diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-12-08 12:13:34 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-08 12:26:20 -0500 |
| commit | fe8d65556dc49bb0da7ee621597c3b24f0e879f6 (patch) | |
| tree | 18af2a2e0e21b1dbec889564f9e49b7992ed20b2 /src/analyze.cpp | |
| parent | 119ed128c05e95a4779a00cd87d3e2d5b01f9f17 (diff) | |
| download | zig-fe8d65556dc49bb0da7ee621597c3b24f0e879f6.tar.gz zig-fe8d65556dc49bb0da7ee621597c3b24f0e879f6.zip | |
add syntax for comptime struct fields
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 37c93c638a..cf7296a9f8 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2736,6 +2736,16 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) { field_node = decl_node->data.container_decl.fields.at(i); type_struct_field->name = field_node->data.struct_field.name; type_struct_field->decl_node = field_node; + if (field_node->data.struct_field.comptime_token != nullptr) { + if (field_node->data.struct_field.value == nullptr) { + add_token_error(g, field_node->owner, + field_node->data.struct_field.comptime_token, + buf_sprintf("comptime struct field missing initialization value")); + struct_type->data.structure.resolve_status = ResolveStatusInvalid; + return ErrorSemanticAnalyzeFail; + } + type_struct_field->is_comptime = true; + } if (field_node->data.struct_field.type == nullptr) { add_node_error(g, field_node, buf_sprintf("struct field missing type")); |
