From: Brendan Hansen Date: Tue, 23 Feb 2021 16:23:44 +0000 (-0600) Subject: making, finding and fixing bugs X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a91fd3c9cacecb706b869543e2405b207c4ccf46;p=onyx.git making, finding and fixing bugs --- diff --git a/bin/onyx b/bin/onyx index 0f8bc0e9..91908319 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/src/onyxastnodes.c b/src/onyxastnodes.c index c3aed5de..0bc14181 100644 --- a/src/onyxastnodes.c +++ b/src/onyxastnodes.c @@ -188,6 +188,7 @@ AstNumLit* ast_reduce_binop(bh_allocator a, AstBinaryOp* node) { AstNumLit* res = onyx_ast_node_new(a, sizeof(AstNumLit), Ast_Kind_NumLit); res->token = node->token; + res->flags |= node->flags; res->flags |= Ast_Flag_Comptime; res->type_node = node->type_node; res->type = node->type; diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 34f674e7..244c202b 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -1096,7 +1096,7 @@ CheckStatus check_struct_literal(AstStructLiteral* sl) { return Check_Error; } - sl->flags &= ((*actual)->flags & Ast_Flag_Comptime); + sl->flags &= ((*actual)->flags & Ast_Flag_Comptime) | (sl->flags &~ Ast_Flag_Comptime); actual++; } @@ -1136,7 +1136,7 @@ CheckStatus check_array_literal(AstArrayLiteral* al) { bh_arr_each(AstTyped *, expr, al->values) { CHECK(expression, expr); - al->flags &= ((*expr)->flags & Ast_Flag_Comptime); + al->flags &= ((*expr)->flags & Ast_Flag_Comptime) | (al->flags &~ Ast_Flag_Comptime); if (!type_check_or_auto_cast(expr, elem_type)) { onyx_report_error((*expr)->token->pos, "Mismatched types for value of in array, expected '%s', got '%s'.", @@ -1579,17 +1579,20 @@ CheckStatus check_block(AstBlock* block) { bh_arr_each(AstTyped *, value, block->allocate_exprs) { fill_in_type(*value); - if ((*value)->type == NULL) { - onyx_report_error((*value)->token->pos, - "Unable to resolve type for local '%b'.", - (*value)->token->text, (*value)->token->length); - return Check_Error; - } - if ((*value)->type->kind == Type_Kind_Compound) { - onyx_report_error((*value)->token->pos, - "Compound type not allowed as local variable type. Try splitting this into multiple variables."); - return Check_Error; + if ((*value)->kind == Ast_Kind_Local) { + if ((*value)->type == NULL) { + onyx_report_error((*value)->token->pos, + "Unable to resolve type for local '%b'.", + (*value)->token->text, (*value)->token->length); + return Check_Error; + } + + if ((*value)->type->kind == Type_Kind_Compound) { + onyx_report_error((*value)->token->pos, + "Compound type not allowed as local variable type. Try splitting this into multiple variables."); + return Check_Error; + } } } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 726e4aea..505d00bf 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -2264,7 +2264,7 @@ EMIT_FUNC(expression, AstTyped* expr) { assert(0); } - if (expr->flags & Ast_Flag_Expr_Ignored && !type_results_in_void(expr->type)) { + if ((expr->flags & Ast_Flag_Expr_Ignored) != 0 && !type_results_in_void(expr->type)) { i32 mem_count = 1; if (type_is_compound(expr->type)) mem_count = type_linear_member_count(expr->type); fori (i, 0, mem_count) WI(WI_DROP);