fixed #47
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 5 Jan 2023 02:24:56 +0000 (20:24 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 5 Jan 2023 02:24:56 +0000 (20:24 -0600)
compiler/src/checker.c

index b3d8a51ed458f537a1a1e36d7fea01fc5384d867..27c6893d4e62db1217b6c22d1c0c9fac3c25b44c 100644 (file)
@@ -2333,7 +2333,17 @@ CheckStatus check_statement(AstNode** pstmt) {
                 CHECK(type, &typed_stmt->type_node);
 
                 if (!node_is_type((AstNode *) typed_stmt->type_node)) {
-                    ERROR(stmt->token->pos, "Local's type is not a type.");
+                    if (typed_stmt->type_node->type == &basic_types[Basic_Kind_Type_Index]) {
+                        onyx_report_error(stmt->token->pos, Error_Critical, "The type of this local variable is a runtime-known type, not a compile-time known type.");
+
+                        if (typed_stmt->type_node->kind == Ast_Kind_Param) {
+                            onyx_report_error(stmt->token->pos, Error_Critical, "Try adding a '$' to the parameter name to make this a compile-time known type.");
+                        }
+
+                        return Check_Error;
+                    } else {
+                        ERROR(stmt->token->pos, "The type of this local is not a type.");
+                    }
                 }
 
                 YIELD(typed_stmt->token->pos, "Waiting for local variable's type.");