bugfix with poly struct params
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 3 Jan 2022 14:57:07 +0000 (08:57 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 3 Jan 2022 14:57:07 +0000 (08:57 -0600)
src/checker.c
src/polymorph.h

index 22bc73fce7cf16406b148d5c1329f4c372496fae..7474af58cb7f1891315183296e3d224dfa4b46d7 100644 (file)
@@ -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");
index 94d8c09d99e28c75fa2cd9c9347f68252c95a69e..94cf396bf308bbbc4a5aa6ae157f07f997837ce4 100644 (file)
@@ -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: