diff options
| author | Mathieu Guay-Paquet <mathieu.guaypaquet@gmail.com> | 2021-02-16 23:43:36 -0500 |
|---|---|---|
| committer | Mathieu Guay-Paquet <mathieu.guaypaquet@gmail.com> | 2021-02-16 23:43:36 -0500 |
| commit | 93f8110e5d9ca7e3ac81b33edd38709fac2c6acd (patch) | |
| tree | 058d70c0bd9568e9a6ffa91c4d4fcaad7b6db68d /src/stage1/ir.cpp | |
| parent | c0cfbe98f3069d1aabb29fb0e795c6582e88b75e (diff) | |
| download | zig-93f8110e5d9ca7e3ac81b33edd38709fac2c6acd.tar.gz zig-93f8110e5d9ca7e3ac81b33edd38709fac2c6acd.zip | |
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.
Diffstat (limited to 'src/stage1/ir.cpp')
| -rw-r--r-- | src/stage1/ir.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index c418149546..0e03f25e11 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -7607,12 +7607,7 @@ static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, bool is_nosuspend = get_scope_nosuspend(scope) != nullptr; CallModifier modifier = node->data.fn_call_expr.modifier; - if (is_nosuspend) { - if (modifier == CallModifierAsync) { - add_node_error(irb->codegen, node, - buf_sprintf("async call in nosuspend scope")); - return irb->codegen->invalid_inst_src; - } + if (is_nosuspend && modifier != CallModifierAsync) { modifier = CallModifierNoSuspend; } |
