aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-03-24 22:05:29 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-03-24 22:07:12 -0400
commitaa2995ee395b2c1329a61513debcac6225fcb8a8 (patch)
treeb96e44da1d55ee671538c775ca5aeb9d91f2c0a7 /test
parenta43c7af3d1e41ccee73678f114bb3844febcaad6 (diff)
downloadzig-aa2995ee395b2c1329a61513debcac6225fcb8a8.tar.gz
zig-aa2995ee395b2c1329a61513debcac6225fcb8a8.zip
fix invalid codegen for error return traces across suspend points
See #821 Now the code works correctly, but error return traces are missing the frames from coroutines.
Diffstat (limited to 'test')
-rw-r--r--test/runtime_safety.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig
index 8b8f612056..1fea6347ab 100644
--- a/test/runtime_safety.zig
+++ b/test/runtime_safety.zig
@@ -281,4 +281,34 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
\\ f.float = 12.34;
\\}
);
+
+ // This case makes sure that the code compiles and runs. There is not actually a special
+ // runtime safety check having to do specifically with error return traces across suspend points.
+ cases.addRuntimeSafety("error return trace across suspend points",
+ \\const std = @import("std");
+ \\
+ \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
+ \\ std.os.exit(126);
+ \\}
+ \\
+ \\pub fn main() void {
+ \\ const p = nonFailing();
+ \\ resume p;
+ \\ const p2 = async<std.debug.global_allocator> printTrace(p) catch unreachable;
+ \\ cancel p2;
+ \\}
+ \\
+ \\fn nonFailing() promise->error!void {
+ \\ return async<std.debug.global_allocator> failing() catch unreachable;
+ \\}
+ \\
+ \\async fn failing() error!void {
+ \\ suspend;
+ \\ return error.Fail;
+ \\}
+ \\
+ \\async fn printTrace(p: promise->error!void) void {
+ \\ (await p) catch unreachable;
+ \\}
+ );
}