From: Brendan Hansen Date: Fri, 8 Dec 2023 20:10:23 +0000 (-0600) Subject: fixed: incorrect WASM binary; refined error messages X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=b74944873d8d95d9737633a55fedce2841c3e2c1;p=onyx.git fixed: incorrect WASM binary; refined error messages --- diff --git a/compiler/src/checker.c b/compiler/src/checker.c index e81a923f..363edabd 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -1100,6 +1100,10 @@ CheckStatus check_binaryop_assignment(AstBinaryOp** pbinop) { } else { fori (i, 0, store_expr_count) { + if (right_type->Compound.types[i] == &basic_types[Basic_Kind_Void]) { + ERROR(lhs->exprs[i]->token->pos, "Due to inference, this variables type would be 'void', which is not allowed."); + } + TRY_ASSIGN_TYPE_OR_FAIL(&lhs->exprs[i], right_type->Compound.types[i], binop->token); } @@ -3293,7 +3297,7 @@ CheckStatus check_function_header(AstFunction* func) { if (param->vararg_kind != VA_Kind_Not_VA) has_had_varargs = 1; if (local->type->kind != Type_Kind_Array && type_size_of(local->type) == 0) { - ERROR(local->token->pos, "Function parameters cannot have zero-width types."); + ERROR(local->token->pos, "Function parameters cannot have 'void' as their type."); } } diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 1be60370..95b51ef3 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -1129,6 +1129,10 @@ EMIT_FUNC(load_instruction, Type* type, u32 offset) { else if (is_basic && (type->Basic.flags & Basic_Flag_SIMD)) { instr = WI_V128_LOAD; } + else if (is_basic && (type->Basic.kind == Basic_Kind_Void)) { + // Do nothing to "load" a void type. + return; + } WID(NULL, instr, ((WasmInstructionData) { alignment, offset }));