mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-13 09:22:22 -07:00
Replace #optional_second with #optional_allocator_error
This commit is contained in:
+9
-10
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user