diff options
| author | avanspector <94762082+avanspector@users.noreply.github.com> | 2025-01-06 16:42:29 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-06 16:42:29 +0400 |
| commit | be7799459be05af307a79d80bd4ac9f61eedac7c (patch) | |
| tree | 4c272a6d20028768f731367fca3325eeceb3567d /src/check_type.cpp | |
| parent | a20d85df1eaf7a24c407256786b714044a87e5ff (diff) | |
| parent | 98efb03934b464a1b23759b5695a12ff37588357 (diff) | |
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 13a6125ca..44108ccbe 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2440,8 +2440,12 @@ gb_internal bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc bool success = true; isize specialization_count = 0; Type *params = check_get_params(c, c->scope, pt->params, &variadic, &variadic_index, &success, &specialization_count, operands); - Type *results = check_get_results(c, c->scope, pt->results); + bool no_poly_return = c->disallow_polymorphic_return_types; + c->disallow_polymorphic_return_types = c->scope == c->polymorphic_scope; + // NOTE(zen3ger): if the parapoly scope is the current proc's scope, then the return types shall not declare new poly vars + Type *results = check_get_results(c, c->scope, pt->results); + c->disallow_polymorphic_return_types = no_poly_return; isize param_count = 0; isize result_count = 0; @@ -3383,6 +3387,9 @@ gb_internal bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, T } Type *t = alloc_type_generic(ctx->scope, 0, token.string, specific); if (ctx->allow_polymorphic_types) { + if (ctx->disallow_polymorphic_return_types) { + error(ident, "Undeclared polymorphic parameter '%.*s' in return type", LIT(token.string)); + } Scope *ps = ctx->polymorphic_scope; Scope *s = ctx->scope; Scope *entity_scope = s; |