diff options
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 66417f97e..c024e0842 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2006,22 +2006,21 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, } } } - if (pt->tags & ProcTag_optional_second) { + if (pt->tags & ProcTag_optional_allocator_error) { if (optional_ok) { - error(proc_type_node, "A procedure type cannot have both an #optional_ok tag and #optional_second"); + error(proc_type_node, "A procedure type cannot have both an #optional_ok tag and #optional_allocator_error"); } optional_ok = true; if (result_count != 2) { - error(proc_type_node, "A procedure type with the #optional_second tag requires 2 return values, got %td", result_count); + error(proc_type_node, "A procedure type with the #optional_allocator_error tag requires 2 return values, got %td", result_count); } else { - bool ok = false; - AstFile *file = proc_type_node->file(); - if (file && file->pkg) { - ok = file->pkg->scope == ctx->info->runtime_package->scope; - } + init_mem_allocator(c->checker); - if (!ok) { - error(proc_type_node, "A procedure type with the #optional_second may only be allowed within 'package runtime'"); + Type *type = results->Tuple.variables[1]->type; + if (!are_types_identical(type, t_allocator_error)) { + gbString t = type_to_string(type); + error(proc_type_node, "A procedure type with the #optional_allocator_error expects a `runtime.Allocator_Error`, got '%s'", t); + gb_string_free(t); } } } |