added new cast syntax; bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 8 Dec 2022 16:36:46 +0000 (10:36 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 8 Dec 2022 16:36:46 +0000 (10:36 -0600)
compiler/src/checker.c
compiler/src/onyx.c
compiler/src/parser.c

index 113682f45811a26baf5339f0b643e1d6045cdbef..23462ce0986d2aa688c0f3da675c005fab45250f 100644 (file)
@@ -171,7 +171,7 @@ CheckStatus check_return(AstReturn* retnode) {
             return Check_Success;
         }
 
-        if ((*expected_return_type)->Basic.size > 0) {
+        if ((*expected_return_type) != &basic_types[Basic_Kind_Void]) {
             ERROR_(retnode->token->pos,
                 "Returning from non-void function without a value. Expected a value of type '%s'.",
                 type_get_name(*expected_return_type));
index a629fa9ecc0a7ed5907ada39dc60d094416e5f1c..d2b071932113f0a1042a4a16d2a77e23e71af617 100644 (file)
@@ -769,7 +769,7 @@ static CompilerProgress onyx_flush_module() {
 
     if (context.options->documentation_file != NULL) {
         OnyxDocumentation docs = onyx_docs_generate();
-        docs.format = Doc_Format_Human;
+        docs.format = Doc_Format_Tags;
         onyx_docs_emit(&docs, context.options->documentation_file);
     }
 
index 77dbcddbf6abb187959ea6c86c50cd7fef8e6d20..cae57cdb6168db0ffc1089e7a379b4f242e11cb2 100644 (file)
@@ -452,9 +452,16 @@ static AstTyped* parse_factor(OnyxParser* parser) {
 
             expect_token(parser, '(');
             cast_node->type_node = parse_type(parser);
-            expect_token(parser, ')');
 
-            cast_node->expr = parse_factor(parser);
+            if (peek_token(0)->type == ',') {
+                expect_token(parser, ',');
+                cast_node->expr = parse_factor(parser);
+                expect_token(parser, ')');
+
+            } else {
+                expect_token(parser, ')');
+                cast_node->expr = parse_factor(parser);
+            }
 
             retval = (AstTyped *) cast_node;
             break;
@@ -1477,6 +1484,7 @@ static AstNode* parse_statement(OnyxParser* parser) {
         case Token_Type_Literal_Integer:
         case Token_Type_Literal_Float:
         case Token_Type_Literal_String:
+        case Token_Type_Keyword_Cast:
             retval = (AstNode *) parse_compound_expression(parser, 1);
             if (retval->kind == Ast_Kind_Call || retval->kind == Ast_Kind_Method_Call) {
                 if (parser->curr->type == '{') {