aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-03 01:06:14 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-03 01:06:14 -0400
commit24d78177eec4d8fc3aa8ca99dd50788e38f9f8b6 (patch)
tree14f0b5e36cb4ec2bc68717c6368afeb06a1b857e /test
parent0920bb087279bdfa317fc88cef877d40ece18239 (diff)
downloadzig-24d78177eec4d8fc3aa8ca99dd50788e38f9f8b6.tar.gz
zig-24d78177eec4d8fc3aa8ca99dd50788e38f9f8b6.zip
add compile error for async call of function pointer
Diffstat (limited to 'test')
-rw-r--r--test/compile_errors.zig12
-rw-r--r--test/stage1/behavior/coroutines.zig8
2 files changed, 16 insertions, 4 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 272d99c930..4b1a24c675 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,18 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "runtime-known function called with async keyword",
+ \\export fn entry() void {
+ \\ var ptr = afunc;
+ \\ _ = async ptr();
+ \\}
+ \\
+ \\async fn afunc() void { }
+ ,
+ "tmp.zig:3:15: error: function is not comptime-known; @asyncCall required",
+ );
+
+ cases.add(
"function with ccc indirectly calling async function",
\\export fn entry() void {
\\ foo();
diff --git a/test/stage1/behavior/coroutines.zig b/test/stage1/behavior/coroutines.zig
index a1c1b7ad61..aa77541d19 100644
--- a/test/stage1/behavior/coroutines.zig
+++ b/test/stage1/behavior/coroutines.zig
@@ -263,15 +263,15 @@ test "async function with dot syntax" {
//test "async fn pointer in a struct field" {
// var data: i32 = 1;
// const Foo = struct {
-// bar: async<*std.mem.Allocator> fn (*i32) void,
+// bar: async fn (*i32) void,
// };
// var foo = Foo{ .bar = simpleAsyncFn2 };
-// const p = (async<allocator> foo.bar(&data)) catch unreachable;
+// const p = async foo.bar(&data);
// expect(data == 2);
-// cancel p;
+// resume p;
// expect(data == 4);
//}
-//async<*std.mem.Allocator> fn simpleAsyncFn2(y: *i32) void {
+//async fn simpleAsyncFn2(y: *i32) void {
// defer y.* += 2;
// y.* += 1;
// suspend;