mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix polymorphic constant parameters for procedures
This commit is contained in:
+6
-1
@@ -1372,7 +1372,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
if (specialization == t_invalid){
|
if (specialization == t_invalid){
|
||||||
specialization = nullptr;
|
specialization = nullptr;
|
||||||
}
|
}
|
||||||
// warning(type_expr, "'type' parameters are deprecated, please use a polymorphic identifier with a type of 'typeid'. For example, '$T: typeid'");
|
|
||||||
|
|
||||||
if (operands != nullptr) {
|
if (operands != nullptr) {
|
||||||
detemine_type_from_operand = true;
|
detemine_type_from_operand = true;
|
||||||
@@ -1555,6 +1554,12 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
p->flags &= ~FieldFlag_auto_cast;
|
p->flags &= ~FieldFlag_auto_cast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_type_constant_type(type) && !is_type_polymorphic(type)) {
|
||||||
|
gbString str = type_to_string(type);
|
||||||
|
error(params[i], "A parameter must be a valid constant type, got %s", str);
|
||||||
|
gb_string_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
param = alloc_entity_const_param(scope, name->Ident.token, type, poly_const, is_type_polymorphic(type));
|
param = alloc_entity_const_param(scope, name->Ident.token, type, poly_const, is_type_polymorphic(type));
|
||||||
} else {
|
} else {
|
||||||
param = alloc_entity_param(scope, name->Ident.token, type, is_using, is_in);
|
param = alloc_entity_param(scope, name->Ident.token, type, is_using, is_in);
|
||||||
|
|||||||
@@ -1396,6 +1396,10 @@ bool are_types_identical(Type *x, Type *y) {
|
|||||||
if (xe->kind != ye->kind || !are_types_identical(xe->type, ye->type)) {
|
if (xe->kind != ye->kind || !are_types_identical(xe->type, ye->type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (xe->kind == Entity_Constant && !compare_exact_values(Token_CmpEq, xe->Constant.value, ye->Constant.value)) {
|
||||||
|
// NOTE(bill): This is needed for polymorphic procedures
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user