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.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index ec661134b..fabbe54c4 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1309,6 +1309,8 @@ gb_internal ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_
init_core_source_code_location(ctx->checker);
param_value.kind = ParameterValue_Location;
o.type = t_source_code_location;
+ o.mode = Addressing_Value;
+ o.expr = expr;
if (in_type) {
check_assignment(ctx, &o, in_type, str_lit("parameter value"));
@@ -1666,17 +1668,21 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
if (is_poly_name) {
bool valid = false;
if (is_type_proc(op.type)) {
- Entity *proc_entity = entity_from_expr(op.expr);
- valid = (proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure);
- if (valid) {
+ Ast *expr = unparen_expr(op.expr);
+ Entity *proc_entity = entity_from_expr(expr);
+ if (proc_entity) {
poly_const = exact_value_procedure(proc_entity->identifier.load() ? proc_entity->identifier.load() : op.expr);
+ valid = true;
+ } else if (expr->kind == Ast_ProcLit) {
+ poly_const = exact_value_procedure(expr);
+ valid = true;
}
}
if (!valid) {
if (op.mode == Addressing_Constant) {
poly_const = op.value;
} else {
- error(op.expr, "Expected a constant value for this polymorphic name parameter");
+ error(op.expr, "Expected a constant value for this polymorphic name parameter, got %s", expr_to_string(op.expr));
success = false;
}
}