From: Brendan Hansen Date: Mon, 3 Jan 2022 14:57:07 +0000 (-0600) Subject: bugfix with poly struct params X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=35d1017c0e1b1bf94a7fc8291c667ef40131691a;p=onyx.git bugfix with poly struct params --- diff --git a/src/checker.c b/src/checker.c index 22bc73fc..7474af58 100644 --- a/src/checker.c +++ b/src/checker.c @@ -500,14 +500,14 @@ static CheckStatus check_resolve_callee(AstCall* call, AstTyped** effective_call callee = new_callee; } - if (!calling_a_macro) call->callee = callee; - // NOTE: Build callee's type fill_in_type((AstTyped *) callee); if (callee->type == NULL) { YIELD(call->token->pos, "Trying to resolve function type for callee."); } + if (!calling_a_macro) call->callee = callee; + if (callee->type->kind != Type_Kind_Function) { ERROR_(call->token->pos, "Attempting to call something that is not a function, '%b'.", @@ -531,7 +531,7 @@ CheckStatus check_call(AstCall** pcall) { // 9. Check types of formal and actual params against each other, handling varargs AstCall* call = *pcall; - { + if (call->kind == Ast_Kind_Call) { AstNode* callee = strip_aliases((AstNode *) call->callee); if (callee->kind == Ast_Kind_Poly_Struct_Type) { // HACK HACK HACK @@ -1699,6 +1699,7 @@ CheckStatus check_expression(AstTyped** pexpr) { case Ast_Kind_Binary_Op: retval = check_binaryop((AstBinaryOp **) pexpr); break; case Ast_Kind_Unary_Op: retval = check_unaryop((AstUnaryOp **) pexpr); break; + case Ast_Kind_Intrinsic_Call: case Ast_Kind_Call: retval = check_call((AstCall **) pexpr); break; case Ast_Kind_Argument: retval = check_argument((AstArgument **) pexpr); break; case Ast_Kind_Block: retval = check_block((AstBlock *) expr); break; @@ -1816,10 +1817,6 @@ CheckStatus check_expression(AstTyped** pexpr) { case Ast_Kind_Unary_Field_Access: break; case Ast_Kind_Constraint_Sentinel: break; - // NOTE: The only way to have an Intrinsic_Call node is to have gone through the - // checking of a call node at least once. - case Ast_Kind_Intrinsic_Call: break; - default: retval = Check_Error; onyx_report_error(expr->token->pos, Error_Critical, "UNEXPECTED INTERNAL COMPILER ERROR"); diff --git a/src/polymorph.h b/src/polymorph.h index 94d8c09d..94cf396b 100644 --- a/src/polymorph.h +++ b/src/polymorph.h @@ -33,6 +33,8 @@ void insert_poly_sln_into_scope(Scope* scope, AstPolySolution *sln) { node = onyx_ast_node_new(context.ast_alloc, sizeof(AstTypeRawAlias), Ast_Kind_Type_Raw_Alias); ((AstTypeRawAlias *) node)->token = sln->poly_sym->token; ((AstTypeRawAlias *) node)->to = sln->type; + ((AstTypeRawAlias *) node)->type = &basic_types[Basic_Kind_Type_Index]; + ((AstTypeRawAlias *) node)->type_id = sln->type->id; break; case PSK_Value: