Skip to content

Commit a896fb2

Browse files
authored
Merge pull request #6507 from LeandroLibanio28H/fixing-declaration-order-bugs
Fixing declaration order bugs
2 parents 039c438 + 8d63c1b commit a896fb2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/check_type.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entit
127127
i32 field_src_index = 0;
128128
i32 field_group_index = -1;
129129
for_array(i, params) {
130+
*fields = slice_from_array(fields_array);
131+
*tags = tags_array.data;
130132
Ast *param = params[i];
131133
if (param->kind != Ast_Field) {
132134
continue;
@@ -796,11 +798,19 @@ gb_internal void check_union_type(CheckerContext *ctx, Type *union_type, Ast *no
796798
if (t != nullptr && t != t_invalid) {
797799
bool ok = true;
798800
t = default_type(t);
799-
if (is_type_untyped(t) || is_type_empty_union(t)) {
801+
if (is_type_untyped(t)) {
800802
ok = false;
801803
gbString str = type_to_string(t);
802804
error(node, "Invalid variant type in union '%s'", str);
803805
gb_string_free(str);
806+
} else if (is_type_empty_union(t)) {
807+
Type *base = base_type(t);
808+
if (base == nullptr || base->kind != Type_Union || base->Union.node == nullptr) {
809+
ok = false;
810+
gbString str = type_to_string(t);
811+
error(node, "Invalid variant type in union '%s'", str);
812+
gb_string_free(str);
813+
}
804814
} else {
805815
for_array(j, variants) {
806816
if (union_variant_index_types_equal(t, variants[j])) {

0 commit comments

Comments
 (0)