From 9a18db8a80c96d206297e865d203b2a7d8a803ba Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 7 Sep 2019 00:27:45 -0400 Subject: [PATCH] properly spill expressions with async function calls --- src/analyze.cpp | 2 ++ test/stage1/behavior/async_fn.zig | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/analyze.cpp b/src/analyze.cpp index bbb5b7192b..d751dbdb97 100644 --- a/src/analyze.cpp +++ b/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, ""); } diff --git a/test/stage1/behavior/async_fn.zig b/test/stage1/behavior/async_fn.zig index cef950fe0c..f5669f0fca 100644 --- a/test/stage1/behavior/async_fn.zig +++ b/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(); +}