From d885fcdd9867e56370be0e7bf4fe9c0a15ace88c Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 22 May 2023 20:12:50 -0500 Subject: [PATCH] cleanup: gcc warnings --- compiler/src/wasm_emit.c | 6 +++--- tests/tagged_unions.onyx | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) 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)); } -- 2.25.1