authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-07 00:27:45-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-07 00:27:45-04:00
log9a18db8a80c96d206297e865d203b2a7d8a803ba
tree925f672055188b9241f2161ce2db60168d691805
parentd1a98ccff481183d7fc53e45a902ef273c3d6aeb
signaturelock-open Commit is signed but in an unrecognized format.

properly spill expressions with async function calls


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

src/analyze.cpp+2
......@@ -5883,6 +5883,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
58835883 if (!fn_is_async(callee))
58845884 continue;
58855885
5886 mark_suspension_point(call->base.scope);
5887
58865888 call->frame_result_loc = ir_create_alloca(g, call->base.scope, call->base.source_node, fn,
58875889 callee_frame_type, "");
58885890 }
test/stage1/behavior/async_fn.zig+15
......@@ -1136,3 +1136,18 @@ test "await used in expression after a fn call" {
11361136 };
11371137 _ = async S.atest();
11381138}
1139
1140test "async fn call used in expression after a fn call" {
1141 const S = struct {
1142 fn atest() void {
1143 var sum: i32 = 0;
1144 sum = foo() + add(3, 4);
1145 expect(sum == 8);
1146 }
1147 async fn add(a: i32, b: i32) i32 {
1148 return a + b;
1149 }
1150 fn foo() i32 { return 1; }
1151 };
1152 _ = async S.atest();
1153}