| author | |
| committer | |
| log | 5a2cbe239f4299b4412209148131a501ec023ceb |
| tree | 1652cb4c4bed1849f818979dd5d41d3a27ede5d3 |
| parent | 2cb1f93894be3f48f0c49004515fa5e8190f69d9 |
| signature |
See #30633 files changed, 18 insertions(+), 2 deletions(-)
src/codegen.cpp+3-1| ... | @@ -5470,7 +5470,9 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutable *executab | ... | @@ -5470,7 +5470,9 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutable *executab |
| 5470 | static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutable *executable, | 5470 | static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutable *executable, |
| 5471 | IrInstructionSuspendBegin *instruction) | 5471 | IrInstructionSuspendBegin *instruction) |
| 5472 | { | 5472 | { |
| 5473 | instruction->resume_bb = gen_suspend_begin(g, "SuspendResume"); | 5473 | if (fn_is_async(g->cur_fn)) { |
| 5474 | instruction->resume_bb = gen_suspend_begin(g, "SuspendResume"); | ||
| 5475 | } | ||
| 5474 | return nullptr; | 5476 | return nullptr; |
| 5475 | } | 5477 | } |
| 5476 | 5478 |
src/ir.cpp+1-1| ... | @@ -7914,7 +7914,7 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod | ... | @@ -7914,7 +7914,7 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod |
| 7914 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); | 7914 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); |
| 7915 | } | 7915 | } |
| 7916 | 7916 | ||
| 7917 | return ir_build_suspend_finish(irb, parent_scope, node, begin); | 7917 | return ir_mark_gen(ir_build_suspend_finish(irb, parent_scope, node, begin)); |
| 7918 | } | 7918 | } |
| 7919 | 7919 | ||
| 7920 | static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scope, | 7920 | static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scope, |
test/stage1/behavior/async_fn.zig+14| ... | @@ -760,3 +760,17 @@ test "async call a generic function" { | ... | @@ -760,3 +760,17 @@ test "async call a generic function" { |
| 760 | }; | 760 | }; |
| 761 | _ = async S.doTheTest(); | 761 | _ = async S.doTheTest(); |
| 762 | } | 762 | } |
| 763 | |||
| 764 | test "return from suspend block" { | ||
| 765 | const S = struct { | ||
| 766 | fn doTheTest() void { | ||
| 767 | expect(func() == 1234); | ||
| 768 | } | ||
| 769 | fn func() i32 { | ||
| 770 | suspend { | ||
| 771 | return 1234; | ||
| 772 | } | ||
| 773 | } | ||
| 774 | }; | ||
| 775 | _ = async S.doTheTest(); | ||
| 776 | } |