From: Brendan Hansen Date: Fri, 8 Dec 2023 18:08:03 +0000 (-0600) Subject: fixed: code generation bug when a local's type is `void` X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a137ae23bab80b0a6463f4fa6d026986b4f2e568;p=onyx.git fixed: code generation bug when a local's type is `void` --- diff --git a/compiler/src/checker.c b/compiler/src/checker.c index 4f929d2a..e81a923f 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -1107,6 +1107,10 @@ CheckStatus check_binaryop_assignment(AstBinaryOp** pbinop) { } } else { + if (right_type == &basic_types[Basic_Kind_Void]) { + ERROR(binop->left->token->pos, "Due to inference, this variables type would be 'void', which is not allowed."); + } + binop->left->type = right_type; } } @@ -2799,6 +2803,11 @@ CheckStatus check_statement(AstNode** pstmt) { typed_stmt->flags |= Ast_Flag_Decl_Followed_By_Init; } } + + if (typed_stmt->type != NULL && typed_stmt->type == &basic_types[Basic_Kind_Void]) { + ERROR(stmt->token->pos, "This local variable has a type of 'void', which is not allowed."); + } + return Check_Success; }