| author | |
| committer | |
| log | 93f8110e5d9ca7e3ac81b33edd38709fac2c6acd |
| tree | 058d70c0bd9568e9a6ffa91c4d4fcaad7b6db68d |
| parent | c0cfbe98f3069d1aabb29fb0e795c6582e88b75e |
Starting an async function call is actually a synchronous operation,
since the caller is not awaiting on the callee for a return value.
This commit removes the compiler code which generates the error and
updates the relevant test case.
In the presence of CallModifierAsync, the callee is expected to
suspend, so it should not be changed to CallModifierNoSuspend.2 files changed, 1 insertions(+), 7 deletions(-)
src/stage1/ir.cpp+1-6| ... | ... | @@ -7607,12 +7607,7 @@ static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, |
| 7607 | 7607 | |
| 7608 | 7608 | bool is_nosuspend = get_scope_nosuspend(scope) != nullptr; |
| 7609 | 7609 | CallModifier modifier = node->data.fn_call_expr.modifier; |
| 7610 | if (is_nosuspend) { | |
| 7611 | if (modifier == CallModifierAsync) { | |
| 7612 | add_node_error(irb->codegen, node, | |
| 7613 | buf_sprintf("async call in nosuspend scope")); | |
| 7614 | return irb->codegen->invalid_inst_src; | |
| 7615 | } | |
| 7610 | if (is_nosuspend && modifier != CallModifierAsync) { | |
| 7616 | 7611 | modifier = CallModifierNoSuspend; |
| 7617 | 7612 | } |
| 7618 | 7613 |
test/compile_errors.zig-1| ... | ... | @@ -1027,7 +1027,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1027 | 1027 | \\} |
| 1028 | 1028 | \\fn foo() void {} |
| 1029 | 1029 | , &[_][]const u8{ |
| 1030 | "tmp.zig:3:21: error: async call in nosuspend scope", | |
| 1031 | 1030 | "tmp.zig:4:9: error: suspend in nosuspend scope", |
| 1032 | 1031 | }); |
| 1033 | 1032 |