Merge pull request #6507 from LeandroLibanio28H/fixing-declaration-order-bugs

Fixing declaration order bugs
This commit is contained in:
gingerBill
2026-04-02 14:32:02 +01:00
committed by GitHub

View File

@@ -127,6 +127,8 @@ gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entit
i32 field_src_index = 0;
i32 field_group_index = -1;
for_array(i, params) {
*fields = slice_from_array(fields_array);
*tags = tags_array.data;
Ast *param = params[i];
if (param->kind != Ast_Field) {
continue;
@@ -796,11 +798,19 @@ gb_internal void check_union_type(CheckerContext *ctx, Type *union_type, Ast *no
if (t != nullptr && t != t_invalid) {
bool ok = true;
t = default_type(t);
if (is_type_untyped(t) || is_type_empty_union(t)) {
if (is_type_untyped(t)) {
ok = false;
gbString str = type_to_string(t);
error(node, "Invalid variant type in union '%s'", str);
gb_string_free(str);
} else if (is_type_empty_union(t)) {
Type *base = base_type(t);
if (base == nullptr || base->kind != Type_Union || base->Union.node == nullptr) {
ok = false;
gbString str = type_to_string(t);
error(node, "Invalid variant type in union '%s'", str);
gb_string_free(str);
}
} else {
for_array(j, variants) {
if (union_variant_index_types_equal(t, variants[j])) {