From: Brendan Hansen Date: Mon, 30 Aug 2021 20:02:22 +0000 (-0500) Subject: quick-function macros; error message cleanup X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=7980d3b416176287cd43af84a3b9c91a3463f5b1;p=onyx.git quick-function macros; error message cleanup --- diff --git a/CHANGELOG b/CHANGELOG index c99f4806..65f4327c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -Release v0.0.7 +Release v0.1.0-beta -------------- This release contains MANY CHANGES because I am terrible at keeping up to date with a proper changelog and release schedule. Basically, this is the first release where I @@ -8,6 +8,10 @@ are going to be changed and added in the future, but first I want to get this be version out there in a packaged format. Additions: +* Quick-Functions +* do-expressions +* typeof +* '#auto' return type * Macros and paste-able code blocks * overloaded procedures can have polymorphic and overloaded procedures as overloads. This makes them MUCH more powerful. * types are not required on struct members that have default values. This is still very experimental so there are some @@ -31,6 +35,7 @@ Additions: Removals: Changes: +* initialization statements on if/while/switch are a lot more powerful. * the "proc" keyword is now optional in a lot of cases. There are inevitably some bugs with this change, but you can always add it in when it may be necessary. Note, that for overloaded procedures, "#match" is now used. diff --git a/bin/onyx b/bin/onyx index 8d2601d3..82cd9f03 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index c7ec01e3..59978901 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -1940,7 +1940,7 @@ CheckStatus check_function(AstFunction* func) { expected_return_type = &func->type->Function.return_type; if (func->body) { CheckStatus status = check_block(func->body); - if (status == Check_Error && func->generated_from) + if (status == Check_Error && func->generated_from && context.cycle_detected == 0) ERROR(func->generated_from->pos, "Error in polymorphic procedure generated from this location."); if (status != Check_Success) return status; diff --git a/src/onyxparser.c b/src/onyxparser.c index 58c34b40..bfc44810 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -2418,7 +2418,12 @@ static AstIf* parse_static_if_stmt(OnyxParser* parser, b32 parse_block_as_statem static AstMacro* parse_macro(OnyxParser* parser) { AstMacro* macro = make_node(AstMacro, Ast_Kind_Macro); macro->token = expect_token(parser, Token_Type_Keyword_Macro); - macro->body = (AstTyped *) parse_function_definition(parser, macro->token); + + // First try quick function + if (!parse_possible_quick_function_definition(parser, ¯o->body)) { + // Otherwise, do a normal function + macro->body = (AstTyped *) parse_function_definition(parser, macro->token); + } ENTITY_SUBMIT(macro); return macro;