Commit 38568318a0

Andrew Kelley <andrew@ziglang.org>
2019-06-23 06:41:11
fix some legacy coroutine stuff
1 parent 7e303fa
Changed files (5)
src/ir.cpp
@@ -15289,6 +15289,21 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrIn
     if (result_loc != nullptr)
         return result_loc;
 
+    ZigFn *fn = exec_fn_entry(ira->new_irb.exec);
+    if (fn != nullptr && fn->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync &&
+            instruction->result_loc->id == ResultLocIdReturn)
+    {
+        result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(),
+                implicit_elem_type, nullptr, false, true);
+        if (result_loc != nullptr &&
+                (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
+        {
+            return result_loc;
+        }
+        result_loc->value.special = ConstValSpecialRuntime;
+        return result_loc;
+    }
+
     IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type);
     result->value.special = ConstValSpecialUndef;
     IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false);
@@ -16128,7 +16143,9 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
         if (handle_is_ptr(impl_fn_type_id->return_type)) {
             result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
                     impl_fn_type_id->return_type, nullptr, true, true);
-            if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
+            if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) ||
+                        instr_is_unreachable(result_loc)))
+            {
                 return result_loc;
             }
         } else {
@@ -16248,7 +16265,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
     if (handle_is_ptr(return_type)) {
         result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
                 return_type, nullptr, true, true);
-        if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
+        if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))) {
             return result_loc;
         }
     } else {
std/event/lock.zig
@@ -123,8 +123,8 @@ pub const Lock = struct {
 };
 
 test "std.event.Lock" {
-    // https://github.com/ziglang/zig/issues/1908
-    if (builtin.single_threaded) return error.SkipZigTest;
+    // https://github.com/ziglang/zig/issues/2377
+    //if (true) return error.SkipZigTest;
 
     var da = std.heap.DirectAllocator.init();
     defer da.deinit();
std/event/net.zig
@@ -263,8 +263,8 @@ pub async fn connect(loop: *Loop, _address: *const std.net.Address) !File {
 }
 
 test "listen on a port, send bytes, receive bytes" {
-    // https://github.com/ziglang/zig/issues/1908
-    if (builtin.single_threaded) return error.SkipZigTest;
+    // https://github.com/ziglang/zig/issues/2377
+    if (true) return error.SkipZigTest;
 
     if (builtin.os != builtin.Os.linux) {
         // TODO build abstractions for other operating systems
std/event/rwlock.zig
@@ -212,8 +212,8 @@ pub const RwLock = struct {
 };
 
 test "std.event.RwLock" {
-    // https://github.com/ziglang/zig/issues/1908
-    if (builtin.single_threaded or builtin.os != builtin.Os.linux) return error.SkipZigTest;
+    // https://github.com/ziglang/zig/issues/2377
+    if (true) return error.SkipZigTest;
 
     var da = std.heap.DirectAllocator.init();
     defer da.deinit();
std/std.zig
@@ -84,7 +84,7 @@ test "std" {
     _ = @import("dwarf.zig");
     _ = @import("dynamic_library.zig");
     _ = @import("elf.zig");
-    //_ = @import("event.zig");
+    _ = @import("event.zig");
     _ = @import("fmt.zig");
     _ = @import("fs.zig");
     _ = @import("hash.zig");