From c546f750f14e63b80c01d707c5559524313edfe4 Mon Sep 17 00:00:00 2001 From: kristopher tate Date: Sat, 28 Jul 2018 23:51:48 +0900 Subject: test/compile_errors.zig: @handle() called outside of function definition; Tracking Issue #1296 ; --- test/compile_errors.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 2c4c9208eb..c34b325a78 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -4738,4 +4738,20 @@ 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", + ); } -- cgit v1.2.3 From 13ec5db2348a0f6a4464aa8a513dbf11b72dc3ae Mon Sep 17 00:00:00 2001 From: kristopher tate Date: Sat, 28 Jul 2018 23:52:12 +0900 Subject: test/compile_errors.zig: @handle() in non-async function Tracking Issue #1296 ; --- test/compile_errors.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index c34b325a78..241f3a47a8 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -4754,4 +4754,18 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { , ".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", + ); } -- cgit v1.2.3 From 51955a5ca2b6f3f005e28cd3758dc481c2eea0c3 Mon Sep 17 00:00:00 2001 From: kristopher tate Date: Sun, 29 Jul 2018 17:18:54 +0900 Subject: test/compile_errors.zig: update test to reflect that the promise symbol is no in scope with suspend; Tracking Issue #1296 ; --- test/compile_errors.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 241f3a47a8..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 { \\ } \\ } \\} -- cgit v1.2.3