CheckStatus check_function_header(AstFunction* func);
CheckStatus check_memres_type(AstMemRes* memres);
CheckStatus check_memres(AstMemRes* memres);
-CheckStatus check_type_alias(AstTypeAlias* type_alias);
+CheckStatus check_type(AstType* type);
static inline void fill_in_type(AstTyped* node);
expect_default_param = 1;
}
+ if (local->type_node != NULL) CHECK(type, local->type_node);
+
fill_in_type((AstTyped *) local);
if (local->type == NULL) {
}
}
+ if (func->return_type != NULL) CHECK(type, func->return_type);
+
func->type = type_build_function_type(semstate.node_allocator, func);
if ((func->flags & Ast_Flag_Exported) != 0) {
return Check_Success;
}
-CheckStatus check_type_alias(AstTypeAlias* type_alias) {
- AstType* to = type_alias->to;
+CheckStatus check_type(AstType* type) {
+ while (type->kind == Ast_Kind_Type_Alias)
+ type = ((AstTypeAlias *) type)->to;
+
+ if (type->kind == Ast_Kind_Poly_Call_Type) {
+ AstPolyCallType* pc_node = (AstPolyCallType *) type;
- if (to->kind == Ast_Kind_Poly_Call_Type) {
- AstPolyCallType* pc_node = (AstPolyCallType *) to;
bh_arr_each(AstNode *, param, pc_node->params) {
if (!node_is_type(*param)) {
CHECK(expression, (AstTyped **) param);
case Entity_Type_Type_Alias:
if (ent->type_alias->kind == Ast_Kind_Struct_Type)
cs = check_struct((AstStructType *) ent->type_alias);
- else if (ent->type_alias->kind == Ast_Kind_Type_Alias)
- check_type_alias((AstTypeAlias *) ent->type_alias);
+ else
+ check_type(ent->type_alias);
break;
case Entity_Type_Memory_Reservation_Type:
if (onyx_has_errors()) return;
}
}
+
+ if ((func->flags & Ast_Flag_From_Polymorphism) == 0) {
+ if (func->overloaded_function != NULL) {
+ symres_expression((AstTyped **) &func->overloaded_function);
+ if (func->overloaded_function == NULL) return; // NOTE: Error message will already be generated
- if (func->overloaded_function != NULL) {
- symres_expression((AstTyped **) &func->overloaded_function);
- if (func->overloaded_function == NULL) return; // NOTE: Error message will already be generated
-
- if (func->overloaded_function->kind != Ast_Kind_Overloaded_Function) {
- onyx_report_error(func->token->pos, "#add_overload directive did not resolve to an overloaded function.");
- return;
+ if (func->overloaded_function->kind != Ast_Kind_Overloaded_Function) {
+ onyx_report_error(func->token->pos, "#add_overload directive did not resolve to an overloaded function.");
+ return;
- } else {
- AstOverloadedFunction* ofunc = (AstOverloadedFunction *) func->overloaded_function;
- bh_arr_push(ofunc->overloads, (AstTyped *) func);
+ } else {
+ AstOverloadedFunction* ofunc = (AstOverloadedFunction *) func->overloaded_function;
+ bh_arr_push(ofunc->overloads, (AstTyped *) func);
+ }
}
- }
- if ((func->flags & Ast_Flag_From_Polymorphism) == 0 && func->operator_overload != (BinaryOp) -1) {
- if (bh_arr_length(func->params) != 2) {
- onyx_report_error(func->token->pos, "Expected 2 exactly arguments for binary operator overload.");
- }
+ if (func->operator_overload != (BinaryOp) -1) {
+ if (bh_arr_length(func->params) != 2) {
+ onyx_report_error(func->token->pos, "Expected 2 exactly arguments for binary operator overload.");
+ }
- if (binop_is_assignment(func->operator_overload)) {
- onyx_report_error(func->token->pos, "'%s' is not currently overloadable.", binaryop_string[func->operator_overload]);
- }
+ if (binop_is_assignment(func->operator_overload)) {
+ onyx_report_error(func->token->pos, "'%s' is not currently overloadable.", binaryop_string[func->operator_overload]);
+ }
- bh_arr_push(operator_overloads[func->operator_overload], (AstTyped *) func);
+ bh_arr_push(operator_overloads[func->operator_overload], (AstTyped *) func);
+ }
}
func->return_type = symres_type(func->return_type);