properly spill expressions with async function calls

This commit is contained in:
Andrew Kelley 2019-09-07 00:27:45 -04:00
parent d1a98ccff4
commit 9a18db8a80
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 17 additions and 0 deletions

View File

@ -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, "");
}

View File

@ -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();
}