diff options
| author | Vexu <git@vexu.eu> | 2020-01-16 09:04:11 +0200 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-01-16 09:04:11 +0200 |
| commit | d84569895c80136d9b081a319301a737f342d251 (patch) | |
| tree | 1c054a3ba13f70b92143fbdc4c92f28e47a16eea /src/analyze.cpp | |
| parent | 02e5cb1cd4203219ae753e94c7e14cd18a918b49 (diff) | |
| download | zig-d84569895c80136d9b081a319301a737f342d251.tar.gz zig-d84569895c80136d9b081a319301a737f342d251.zip | |
turn panics into compile errors, require at least 1 field in non-exhaustive enum
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 7669e0890b..a9aaf74a85 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2560,7 +2560,8 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { assert(!enum_type->data.enumeration.fields); uint32_t field_count = (uint32_t)decl_node->data.container_decl.fields.length; - if (field_count == 0) { + if (field_count == 0 || (field_count == 1 && + buf_eql_str(decl_node->data.container_decl.fields.at(0)->data.struct_field.name, "_"))) { add_node_error(g, decl_node, buf_sprintf("enums must have 1 or more fields")); enum_type->data.enumeration.src_field_count = field_count; |
