mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Allow async in nosuspend scope
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.
This commit is contained in:
parent
c0cfbe98f3
commit
93f8110e5d
2 changed files with 1 additions and 7 deletions
|
|
@ -7607,12 +7607,7 @@ static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node,
|
||||||
|
|
||||||
bool is_nosuspend = get_scope_nosuspend(scope) != nullptr;
|
bool is_nosuspend = get_scope_nosuspend(scope) != nullptr;
|
||||||
CallModifier modifier = node->data.fn_call_expr.modifier;
|
CallModifier modifier = node->data.fn_call_expr.modifier;
|
||||||
if (is_nosuspend) {
|
if (is_nosuspend && modifier != CallModifierAsync) {
|
||||||
if (modifier == CallModifierAsync) {
|
|
||||||
add_node_error(irb->codegen, node,
|
|
||||||
buf_sprintf("async call in nosuspend scope"));
|
|
||||||
return irb->codegen->invalid_inst_src;
|
|
||||||
}
|
|
||||||
modifier = CallModifierNoSuspend;
|
modifier = CallModifierNoSuspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1027,7 +1027,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||||
\\}
|
\\}
|
||||||
\\fn foo() void {}
|
\\fn foo() void {}
|
||||||
, &[_][]const u8{
|
, &[_][]const u8{
|
||||||
"tmp.zig:3:21: error: async call in nosuspend scope",
|
|
||||||
"tmp.zig:4:9: error: suspend in nosuspend scope",
|
"tmp.zig:4:9: error: suspend in nosuspend scope",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue