mirror of
https://github.com/odin-lang/Odin.git
synced 2026-03-03 15:18:20 +00:00
Reverted the main proc changed, after a chat with Bill about better solutions.
This commit is contained in:
@@ -249,30 +249,13 @@ void check_proc_lit(Checker *c, Entity *e, DeclInfo *d) {
|
||||
bool is_no_inline = (pd->tags & ProcTag_no_inline) != 0;
|
||||
|
||||
if ((d->scope->is_file || d->scope->is_global) &&
|
||||
str_eq(e->token.string, str_lit("main"))) {
|
||||
str_eq(e->token.string, str_lit("main"))) {
|
||||
if (proc_type != NULL) {
|
||||
TypeProc *pt = &proc_type->Proc;
|
||||
|
||||
// This is an ugly monstrosity, but I see no other way.
|
||||
bool valid_param = pt->param_count == 0 || (pt->params->kind == Type_Tuple &&
|
||||
pt->params->Tuple.variable_count == 2 &&
|
||||
pt->params->Tuple.variables[0]->kind == Entity_Variable &&
|
||||
pt->params->Tuple.variables[0]->type->kind == Type_Basic &&
|
||||
pt->params->Tuple.variables[0]->type->Basic.kind == Basic_i32 &&
|
||||
pt->params->Tuple.variables[1]->kind == Entity_Variable &&
|
||||
pt->params->Tuple.variables[1]->type->kind == Type_Slice &&
|
||||
pt->params->Tuple.variables[1]->type->Slice.elem->kind == Type_Pointer &&
|
||||
pt->params->Tuple.variables[1]->type->Slice.elem->Pointer.elem->kind == Type_Basic &&
|
||||
pt->params->Tuple.variables[1]->type->Slice.elem->Pointer.elem->Basic.kind == Basic_u8);
|
||||
|
||||
bool valid_result = pt->result_count == 0 || (pt->results->kind == Type_Tuple &&
|
||||
pt->results->Tuple.variable_count == 1 &&
|
||||
pt->results->Tuple.variables[0]->kind == Entity_Variable &&
|
||||
pt->results->Tuple.variables[0]->type->kind == Type_Basic &&
|
||||
pt->results->Tuple.variables[0]->type->Basic.kind == Basic_i32);
|
||||
if (!valid_param || !valid_result) {
|
||||
if (pt->param_count != 0 ||
|
||||
pt->result_count != 0) {
|
||||
gbString str = type_to_string(proc_type);
|
||||
error(e->token, "Procedure type of `main` was expected to be `proc()` or `proc(i32, []^byte) -> i32`, got %s", str);
|
||||
error(e->token, "Procedure type of `main` was expected to be `proc()`, got %s", str);
|
||||
gb_string_free(str);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user