From cb248898ab41378c2e9bcf94d05c7c42577a7bab Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Mon, 22 Nov 2021 02:52:26 +0100 Subject: sema: error union in-memory coercion --- test/behavior/error.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/behavior/error.zig') 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) {} -- cgit v1.2.3