aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 089e66c4d..6df824ec1 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -469,7 +469,9 @@ void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array<
is_polymorphic = true;
can_check_fields = false;
}
- e = alloc_entity_constant(scope, token, operand.type, operand.value);
+ if (e == nullptr) {
+ e = alloc_entity_constant(scope, token, operand.type, operand.value);
+ }
}
} else {
if (is_type_param) {
@@ -1672,11 +1674,19 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
}
}
if (is_poly_name) {
- if (op.mode == Addressing_Constant) {
- poly_const = op.value;
- } else {
- error(op.expr, "Expected a constant value for this polymorphic name parameter");
- success = false;
+ bool valid = false;
+ if (is_type_proc(op.type)) {
+ Entity *proc_entity = entity_from_expr(op.expr);
+ valid = proc_entity != nullptr;
+ poly_const = exact_value_procedure(proc_entity->identifier ? proc_entity->identifier : op.expr);
+ }
+ if (!valid) {
+ if (op.mode == Addressing_Constant) {
+ poly_const = op.value;
+ } else {
+ error(op.expr, "Expected a constant value for this polymorphic name parameter");
+ success = false;
+ }
}
}
if (is_type_untyped(default_type(type))) {