diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-17 19:47:49 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-17 19:47:49 -0400 |
| commit | ea1734773ba9913e32318aba963cdcb9f51128d4 (patch) | |
| tree | f828d07b7c5b9e4cc550ddf7aab21c9ac166b466 /test | |
| parent | 57b90d2d98154e382c58f1b385de2bcef132f7d9 (diff) | |
| download | zig-ea1734773ba9913e32318aba963cdcb9f51128d4.tar.gz zig-ea1734773ba9913e32318aba963cdcb9f51128d4.zip | |
add compile error for async frames depending on themselves
Diffstat (limited to 'test')
| -rw-r--r-- | test/compile_errors.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 654171f553..cecb37620c 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3,6 +3,42 @@ const builtin = @import("builtin"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "indirect recursion of async functions detected", + \\var frame: ?anyframe = null; + \\ + \\export fn a() void { + \\ _ = async rangeSum(10); + \\ while (frame) |f| resume f; + \\} + \\ + \\fn rangeSum(x: i32) i32 { + \\ suspend { + \\ frame = @frame(); + \\ } + \\ frame = null; + \\ + \\ if (x == 0) return 0; + \\ var child = rangeSumIndirect(x - 1); + \\ return child + 1; + \\} + \\ + \\fn rangeSumIndirect(x: i32) i32 { + \\ suspend { + \\ frame = @frame(); + \\ } + \\ frame = null; + \\ + \\ if (x == 0) return 0; + \\ var child = rangeSum(x - 1); + \\ return child + 1; + \\} + , + "tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself", + "tmp.zig:15:33: note: when analyzing type '@Frame(rangeSumIndirect)' here", + "tmp.zig:26:25: note: when analyzing type '@Frame(rangeSum)' here", + ); + + cases.add( "non-async function pointer eventually is inferred to become async", \\export fn a() void { \\ var non_async_fn: fn () void = undefined; |
