aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-11-22 02:52:26 +0100
committerRobin Voetter <robin@voetter.nl>2021-11-22 03:21:31 +0100
commitcb248898ab41378c2e9bcf94d05c7c42577a7bab (patch)
tree97d571db34045fe9a5dd1fe9e98d678e5b7f31cd /test/behavior/error.zig
parent83a0329c92dc8302b7098f718ceed2ed00e9fda2 (diff)
downloadzig-cb248898ab41378c2e9bcf94d05c7c42577a7bab.tar.gz
zig-cb248898ab41378c2e9bcf94d05c7c42577a7bab.zip
sema: error union in-memory coercion
Diffstat (limited to 'test/behavior/error.zig')
-rw-r--r--test/behavior/error.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index edbe866b95..b7d4511fe9 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -115,3 +115,19 @@ test "implicit cast to optional to error union to return result loc" {
try S.entry();
//comptime S.entry(); TODO
}
+
+test "error: fn returning empty error set can be passed as fn returning any error" {
+ entry();
+ comptime entry();
+}
+
+fn entry() void {
+ foo2(bar2);
+}
+
+fn foo2(f: fn () anyerror!void) void {
+ const x = f();
+ x catch {};
+}
+
+fn bar2() (error{}!void) {}