Commit 9a18db8a80
Changed files (2)
src
test
stage1
behavior
src/analyze.cpp
@@ -5883,6 +5883,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
if (!fn_is_async(callee))
continue;
+ mark_suspension_point(call->base.scope);
+
call->frame_result_loc = ir_create_alloca(g, call->base.scope, call->base.source_node, fn,
callee_frame_type, "");
}
test/stage1/behavior/async_fn.zig
@@ -1136,3 +1136,18 @@ test "await used in expression after a fn call" {
};
_ = async S.atest();
}
+
+test "async fn call used in expression after a fn call" {
+ const S = struct {
+ fn atest() void {
+ var sum: i32 = 0;
+ sum = foo() + add(3, 4);
+ expect(sum == 8);
+ }
+ async fn add(a: i32, b: i32) i32 {
+ return a + b;
+ }
+ fn foo() i32 { return 1; }
+ };
+ _ = async S.atest();
+}