From: Brendan Hansen Date: Tue, 23 May 2023 01:12:50 +0000 (-0500) Subject: cleanup: gcc warnings X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=d885fcdd9867e56370be0e7bf4fe9c0a15ace88c;p=onyx.git cleanup: gcc warnings --- diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 48281539..5de1db7c 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -1703,7 +1703,7 @@ EMIT_FUNC(switch, AstSwitch* switch_node) { assert(union_capture_idx != 0); if (sc->capture_is_by_pointer) { - u64 capture_pointer_local = emit_local_allocation(mod, &code, sc->capture); + u64 capture_pointer_local = emit_local_allocation(mod, &code, (AstTyped *) sc->capture); WIL(NULL, WI_LOCAL_GET, union_capture_idx); WIL(NULL, WI_PTR_CONST, switch_node->expr->type->Union.alignment); @@ -1715,8 +1715,8 @@ EMIT_FUNC(switch, AstSwitch* switch_node) { sc->capture->flags |= Ast_Flag_Decl_Followed_By_Init; sc->capture->flags |= Ast_Flag_Address_Taken; - emit_local_allocation(mod, &code, sc->capture); - emit_location(mod, &code, sc->capture); + emit_local_allocation(mod, &code, (AstTyped *) sc->capture); + emit_location(mod, &code, (AstTyped *) sc->capture); WIL(NULL, WI_LOCAL_GET, union_capture_idx); WIL(NULL, WI_PTR_CONST, switch_node->expr->type->Union.alignment); diff --git a/tests/tagged_unions.onyx b/tests/tagged_unions.onyx index a5f24699..3365fa0d 100644 --- a/tests/tagged_unions.onyx +++ b/tests/tagged_unions.onyx @@ -13,13 +13,16 @@ unwrap_optional :: (o: NewOptional($T)) -> T { } } +create_optional :: () -> NewOptional(i32) { + return .{ Some = i32 }; +} + new_optional_test :: () { - v := NewOptional(i32).{ Some = 123 }; + v := create_optional(); v2 := NewOptional(str).{ None = .{} }; println(v); println(v2); - v = .{ None = .{} }; println(unwrap_optional(v)); }