improvements to @asyncCall

* `await @asyncCall` generates better code. See #3065
 * `@asyncCall` works with a real `@Frame(func)` in addition to
   a byte slice. Closes #3072
 * `@asyncCall` allows passing `{}` (a void value) as the result
   pointer, which uses the result location inside the frame.
   Closes #3068
 * support `await @asyncCall` on a non-async function. This is in
   preparation for safe recursion (#1006).
This commit is contained in:
Andrew Kelley
2019-08-31 18:50:16 -04:00
parent a223063923
commit 5c3a9a1a3e
6 changed files with 308 additions and 105 deletions

View File

@@ -2,6 +2,22 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"wrong type for result ptr to @asyncCall",
\\export fn entry() void {
\\ _ = async amain();
\\}
\\fn amain() i32 {
\\ var frame: @Frame(foo) = undefined;
\\ return await @asyncCall(&frame, false, foo);
\\}
\\fn foo() i32 {
\\ return 1234;
\\}
,
"tmp.zig:6:37: error: expected type '*i32', found 'bool'",
);
cases.add(
"struct depends on itself via optional field",
\\const LhsExpr = struct {