authorgravatar for mathieu.guaypaquet@gmail.comMathieu Guay-Paquet <mathieu.guaypaquet@gmail.com> 2021-02-16 21:51:19-05:00
committergravatar for mathieu.guaypaquet@gmail.comMathieu Guay-Paquet <mathieu.guaypaquet@gmail.com> 2021-02-16 21:51:19-05:00
logc0cfbe98f3069d1aabb29fb0e795c6582e88b75e
treed1ffeb7de1307ff580f23d729b8f39a3f8e95505
parent9270aae071a4ee840193afe1162b24945cbd6d9e

Allow resume in nosuspend scope

Resuming a suspended async function call is actually a synchronous operation. This commit removes the compiler code which generates the error and updates the relevant test case.

2 files changed, 0 insertions(+), 5 deletions(-)

src/stage1/ir.cpp-4
...@@ -10095,10 +10095,6 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod...@@ -10095,10 +10095,6 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
1009510095
10096static IrInstSrc *ir_gen_resume(IrBuilderSrc *irb, Scope *scope, AstNode *node) {10096static IrInstSrc *ir_gen_resume(IrBuilderSrc *irb, Scope *scope, AstNode *node) {
10097 assert(node->type == NodeTypeResume);10097 assert(node->type == NodeTypeResume);
10098 if (get_scope_nosuspend(scope) != nullptr) {
10099 add_node_error(irb->codegen, node, buf_sprintf("resume in nosuspend scope"));
10100 return irb->codegen->invalid_inst_src;
10101 }
1010210098
10103 IrInstSrc *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr);10099 IrInstSrc *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr);
10104 if (target_inst == irb->codegen->invalid_inst_src)10100 if (target_inst == irb->codegen->invalid_inst_src)
test/compile_errors.zig-1
...@@ -1029,7 +1029,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1029,7 +1029,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1029 , &[_][]const u8{1029 , &[_][]const u8{
1030 "tmp.zig:3:21: error: async call in nosuspend scope",1030 "tmp.zig:3:21: error: async call in nosuspend scope",
1031 "tmp.zig:4:9: error: suspend in nosuspend scope",1031 "tmp.zig:4:9: error: suspend in nosuspend scope",
1032 "tmp.zig:5:9: error: resume in nosuspend scope",
1033 });1032 });
10341033
1035 cases.add("atomicrmw with bool op not .Xchg",1034 cases.add("atomicrmw with bool op not .Xchg",