This commit is contained in:
gingerBill
2024-05-09 10:58:57 +01:00
parent 97e9c50d11
commit d85c8f0b2c
4 changed files with 17 additions and 0 deletions
+11
View File
@@ -1619,6 +1619,17 @@ gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *de
if (e->kind != Entity_Variable) {
continue;
}
if (is_type_polymorphic(e->type)) {
gbString s = type_to_string(e->type);
char const *msg = "Unspecialized polymorphic types are not allowed in procedure parameters, got %s";
if (e->Variable.type_expr) {
error(e->Variable.type_expr, msg, s);
} else {
error(e->token, msg, s);
}
gb_string_free(s);
}
if (!(e->flags & EntityFlag_Using)) {
continue;
}
+1
View File
@@ -2076,6 +2076,7 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
param = alloc_entity_param(scope, name->Ident.token, type, is_using, true);
param->Variable.param_value = param_value;
param->Variable.field_group_index = field_group_index;
param->Variable.type_expr = type_expr;
}
}
if (p->flags&FieldFlag_no_alias) {
+1
View File
@@ -210,6 +210,7 @@ struct Entity {
CommentGroup *comment;
} Constant;
struct {
Ast *type_expr; // only used for some variables within procedure bodies
Ast *init_expr; // only used for some variables within procedure bodies
i32 field_index;
i32 field_group_index;
+4
View File
@@ -3267,6 +3267,10 @@ gb_internal Selection lookup_field_with_selection(Type *type_, String field_name
}
}
if (is_type_polymorphic(type)) {
// NOTE(bill): A polymorphic struct has no fields, this only hits in the case of an error
return sel;
}
wait_signal_until_available(&type->Struct.fields_wait_signal);
isize field_count = type->Struct.fields.count;
if (field_count != 0) for_array(i, type->Struct.fields) {