From: Brendan Hansen Date: Sun, 12 Mar 2023 20:30:41 +0000 (-0500) Subject: bugfix: js platform and `void` structure literals X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=23b8800d09c23621103d5af13fb1e72068e043ce;p=onyx.git bugfix: js platform and `void` structure literals --- diff --git a/compiler/src/checker.c b/compiler/src/checker.c index b9f6fbe3..a60be7c6 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -1447,6 +1447,11 @@ CheckStatus check_struct_literal(AstStructLiteral* sl) { // If there are no given arguments to a structure literal, it is treated as a 'zero-value', // and can be used to create a completely zeroed value of any type. if (bh_arr_length(sl->args.values) == 0 && bh_arr_length(sl->args.named_values) == 0) { + if (sl->type->kind == Type_Kind_Basic && + sl->type->Basic.kind == Basic_Kind_Void) { + ERROR(sl->token->pos, "Cannot produce a zero-value for 'void' type."); + } + AstZeroValue *zv = make_zero_value(context.ast_alloc, sl->token, sl->type); bh_arr_push(sl->args.values, (AstTyped *) zv); diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 1fda5143..1fa59527 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -4145,6 +4145,10 @@ static char encode_type_as_dyncall_symbol(Type *t) { if (basic->size == 0) return 'v'; } + if (t->kind == Type_Kind_Distinct) { + return encode_type_as_dyncall_symbol(t->Distinct.base_type); + } + return 'v'; } diff --git a/core/runtime/platform/js/platform.onyx b/core/runtime/platform/js/platform.onyx index aa304e2a..38b01b7f 100644 --- a/core/runtime/platform/js/platform.onyx +++ b/core/runtime/platform/js/platform.onyx @@ -4,8 +4,6 @@ use core use runtime { __runtime_initialize, Multi_Threading_Enabled, - _thread_start, - _thread_exit } // Platform supports @@ -43,6 +41,6 @@ __start :: () { __spawn_thread :: (id: i32, tls_base: rawptr, func: (data: rawptr) -> void, data: rawptr) -> bool #foreign "host" "spawn_thread" --- __kill_thread :: (id: i32) -> i32 #foreign "host" "kill_thread" --- - #export "_thread_start" _thread_start - #export "_thread_exit" _thread_exit + #export "_thread_start" runtime._thread_start + #export "_thread_exit" runtime._thread_exit }