From 38568318a087394f02cba21a9617098ccb8b58ee Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 23 Jun 2019 00:41:11 -0400 Subject: [PATCH] fix some legacy coroutine stuff --- src/ir.cpp | 21 +++++++++++++++++++-- std/event/lock.zig | 4 ++-- std/event/net.zig | 4 ++-- std/event/rwlock.zig | 4 ++-- std/std.zig | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index f73c3f0d45a0..32e3692afd0b 100644 --- a/src/ir.cpp +++ b/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 { diff --git a/std/event/lock.zig b/std/event/lock.zig index 031b2adf1984..86b684fea36b 100644 --- a/std/event/lock.zig +++ b/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(); diff --git a/std/event/net.zig b/std/event/net.zig index 413bf1432cbf..46b724e32ee7 100644 --- a/std/event/net.zig +++ b/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 diff --git a/std/event/rwlock.zig b/std/event/rwlock.zig index 00f3c0bc6030..6dd3c0bcd11b 100644 --- a/std/event/rwlock.zig +++ b/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(); diff --git a/std/std.zig b/std/std.zig index 320cc1e8ce9c..1bf60f70ca5b 100644 --- a/std/std.zig +++ b/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");