cleanup: gcc warnings
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 May 2023 01:12:50 +0000 (20:12 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 May 2023 01:12:50 +0000 (20:12 -0500)
compiler/src/wasm_emit.c
tests/tagged_unions.onyx

index 48281539451d94edd5006255fdd9cafcc2ad0e8b..5de1db7c31a4c270a58fca12d5c1e86c7f0fe8ee 100644 (file)
@@ -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);
index a5f24699f469cad4b5850dadf1629e819f0f1016..3365fa0d028c625a9a69569a2188aa87a06b3480 100644 (file)
@@ -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));
 }