aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-08-02 13:37:24 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-08-02 13:37:24 -0400
commit44fd3045ce85abb3e10dc0ad70d195b7d8044c43 (patch)
treea5b027f354a392cf360a69a9049311320fdf08ba /test/compile_errors.zig
parent9ecbabfc4ce857e43db2b056bc83272cb24b0bbd (diff)
parent96a94e7da933dafec25356c435f5725c3cb0ce04 (diff)
downloadzig-44fd3045ce85abb3e10dc0ad70d195b7d8044c43.tar.gz
zig-44fd3045ce85abb3e10dc0ad70d195b7d8044c43.zip
Merge branch 'handle-builtin-issue1296' of https://github.com/kristate/zig into kristate-handle-builtin-issue1296
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig34
1 files changed, 32 insertions, 2 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 2c4c9208eb..f4b289f70d 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -367,8 +367,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\}
\\
\\async fn foo() void {
- \\ suspend |p| {
- \\ suspend |p1| {
+ \\ suspend {
+ \\ suspend {
\\ }
\\ }
\\}
@@ -4738,4 +4738,34 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
,
".tmp_source.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
);
+
+ cases.add(
+ "@handle() called outside of function definition",
+ \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
+ \\ @import("std").os.exit(126);
+ \\}
+ \\
+ \\var handle_undef: promise = undefined;
+ \\var handle_dummy: promise = @handle();
+ \\
+ \\pub fn main() void {
+ \\ if (handle_undef == handle_dummy) return 0;
+ \\}
+ ,
+ ".tmp_source.zig:6:29: error: @handle() called outside of function definition",
+ );
+
+ cases.add(
+ "@handle() in non-async function",
+ \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
+ \\ @import("std").os.exit(126);
+ \\}
+ \\
+ \\pub fn main() void {
+ \\ var handle_undef: promise = undefined;
+ \\ if (handle_undef == @handle()) return 0;
+ \\}
+ ,
+ ".tmp_source.zig:7:25: error: @handle() in non-async function",
+ );
}