mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
properly spill expressions with async function calls
This commit is contained in:
parent
d1a98ccff4
commit
9a18db8a80
@ -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, "");
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user