authorgravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-07-28 15:20:56+09:00
committergravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-08-02 16:50:08+09:00
log0ee65025623c0440ed655d68b579f17e6d6e5f5c
tree83c3eac2fffd756292582d90c8bd319e4c15fdda
parent81f463626ad09dd09e525cda140fb63baf11bc73

src/codegen.cpp: remove `add_node_error` from `ir_render_handle`;

Tracking Issue #1296 ; Thanks @andrewrk ;

2 files changed, 4 insertions(+), 11 deletions(-)

src/codegen.cpp+1-11
......@@ -4149,17 +4149,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutable *executable
41494149static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutable *executable,
41504150 IrInstructionHandle *instruction)
41514151{
4152
4153 bool is_async = executable->fn_entry != nullptr &&
4154 executable->fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync;
4155
4156 if (!is_async || !executable->coro_handle) {
4157 add_node_error(g, instruction->base.source_node, buf_sprintf("@handle() in non-async function"));
4158 return LLVMConstNull(g->builtin_types.entry_promise->type_ref);
4159 }
4160
4161 LLVMValueRef handle = ir_llvm_value(g, executable->coro_handle);
4162 return LLVMBuildRet(g->builder, handle);
4152 return LLVMConstNull(g->builtin_types.entry_promise->type_ref);
41634153}
41644154
41654155static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstructionOverflowOp *instruction) {
test/cases/coroutines.zig+3
......@@ -57,6 +57,9 @@ test "coroutine suspend with block" {
5757 resume a_promise;
5858 std.debug.assert(result);
5959 cancel p;
60
61 assert( @handle() );
62
6063}
6164
6265var a_promise: promise = undefined;