| ... | @@ -2679,6 +2679,13 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) { | ... | @@ -2679,6 +2679,13 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) { |
| 2679 | buf_sprintf("enums, not structs, support field assignment")); | 2679 | buf_sprintf("enums, not structs, support field assignment")); |
| 2680 | } | 2680 | } |
| 2681 | | 2681 | |
| | 2682 | if (field_type->id == ZigTypeIdOpaque) { |
| | 2683 | add_node_error(g, field_node->data.struct_field.type, |
| | 2684 | buf_sprintf("opaque types have unknown size and therefore cannot be directly embedded in structs")); |
| | 2685 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; |
| | 2686 | continue; |
| | 2687 | } |
| | 2688 | |
| 2682 | switch (type_requires_comptime(g, field_type)) { | 2689 | switch (type_requires_comptime(g, field_type)) { |
| 2683 | case ReqCompTimeYes: | 2690 | case ReqCompTimeYes: |
| 2684 | struct_type->data.structure.requires_comptime = true; | 2691 | struct_type->data.structure.requires_comptime = true; |
| ... | @@ -2963,6 +2970,13 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { | ... | @@ -2963,6 +2970,13 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { |
| 2963 | } | 2970 | } |
| 2964 | union_field->type_entry = field_type; | 2971 | union_field->type_entry = field_type; |
| 2965 | | 2972 | |
| | 2973 | if (field_type->id == ZigTypeIdOpaque) { |
| | 2974 | add_node_error(g, field_node->data.struct_field.type, |
| | 2975 | buf_sprintf("opaque types have unknown size and therefore cannot be directly embedded in unions")); |
| | 2976 | union_type->data.unionation.is_invalid = true; |
| | 2977 | continue; |
| | 2978 | } |
| | 2979 | |
| 2966 | switch (type_requires_comptime(g, field_type)) { | 2980 | switch (type_requires_comptime(g, field_type)) { |
| 2967 | case ReqCompTimeInvalid: | 2981 | case ReqCompTimeInvalid: |
| 2968 | union_type->data.unionation.is_invalid = true; | 2982 | union_type->data.unionation.is_invalid = true; |