aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-05-09 08:35:16 +0100
committerGitHub <noreply@github.com>2025-05-09 08:35:16 +0100
commit23aff08556589a80d886cceb3482428507e7c46f (patch)
tree9ee38691a31346fdc534976cca8cbfea259a5045 /src/check_type.cpp
parent10d83323949a11364c77c6a6c32196990509870b (diff)
parent3c0ba5bb55fe59ed1644c3e61fd2a81fb856624e (diff)
Merge pull request #5117 from bogwi/bug/5024
Bug/5024
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 452da4023..431698459 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1910,9 +1910,18 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
case ParameterValue_Location:
case ParameterValue_Expression:
case ParameterValue_Value:
+ // Special case for polymorphic procedures as default values
+ if (param_value.ast_value != nullptr) {
+ Entity *e = entity_from_expr(param_value.ast_value);
+ if (e != nullptr && e->kind == Entity_Procedure && is_type_polymorphic(e->type)) {
+ // Allow polymorphic procedures as default parameter values
+ // The type will be correctly determined at call site
+ break;
+ }
+ }
gbString str = type_to_string(type);
error(params[i], "A default value for a parameter must not be a polymorphic constant type, got %s", str);
- gb_string_free(str);
+ gb_string_free(str);
break;
}
}